Using GUI Textbox.Text for creating a Folder and adding subfolder

250 Views Asked by At

I am trying to create a GUI which always should create a folder with the string from a textbox and after add oder Item and folder

With the First Button i create the folder using the string from the textbox With the Butto "save" another folder should be added to the new created folder

Here my script

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$window = New-Object System.Windows.Forms.Form
$window.Width = 1300
$window.Height = 1000
$window.Text = "Project Management Dashboard"

$Label1 = New-Object System.Windows.Forms.Label
$Label1.Location = New-Object System.Drawing.Size(10,10)
$Label1.Text = "Creator"
$Label1.AutoSize = $True
$Label1.ForeColor = "Black"
$window.Controls.Add($Label1)
 
  $windowTextBox1 = New-Object System.Windows.Forms.TextBox
  $windowTextBox1.Location = New-Object System.Drawing.Size(10,40)
  $windowTextBox1.Size = New-Object System.Drawing.Size (300,500)
 
  $window.Controls.Add($windowTextBox1)

$windowsbuttonquery = New-Object System.Windows.Forms.Button
$windowsbuttonquery.Location = New-Object System.Drawing.Point(400,800)
$windowsbuttonquery.Size = New-Object System.Drawing.Size(175,80)
$windowsbuttonquery.Text = "Project Package"
$windowsbuttonquery.ForeColor = "Black"
$window.Controls.Add($windowsbuttonquery)

$windowsbuttonquery.Add_Click({

New-Item -Path C:\Test_Ps1 -Name $windowTextBox1.Text -ItemType directory

}
)

$save = New-Object System.Windows.Forms.Button
$save.Location = New-Object System.Drawing.Point(700,800)
$save.Size = New-Object System.Drawing.Size(175,80)
$save.Text = "SAVE"
$save.ForeColor = "Black"
$window.Controls.Add($save)

$save.Add_Click({

$to = "c:\Test_Ps1\$windowTextBox1.Text"

Copy-Item -Path C:\Test_Ps1\Z -Destination $to

$window.Dispose()
}
)

[void]$window.ShowDialog()

Thanks for help.

0

There are 0 best solutions below