Adding File Location into a Text Box
Posted: Tue Feb 05, 2019 2:41 pm
Hi,
I am new to PowerShell, and very new to PowerShell Studio.
I have a script that involves specifying a filename, and adding this filename and path into a textbox.
I am struggling to get the correct data to be show in the textbox, and calling on the variable in the console shows as Null.
Can any one help please?
Thanks.
I am new to PowerShell, and very new to PowerShell Studio.
I have a script that involves specifying a filename, and adding this filename and path into a textbox.
I am struggling to get the correct data to be show in the textbox, and calling on the variable in the console shows as Null.
- Function Get-FileLocImport ($initialDirectoryImport)
- {
- [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
- $OpenFileDialogIn = New-Object System.Windows.Forms.OpenFileDialog
- $OpenFileDialogIn.initialDirectory = $initialDirectoryImport
- $OpenFileDialogIn.filter = "Excel (*.xlsx)| *.xlsx|Excel (*.xls)| *.xls|CSV - Comma Delimited (*.csv)| *.csv|All files (*.*)|*.*"
- $OpenFileDialogIn.ShowDialog() | Out-Null
- $OpenFileDialogIn.filename
- $OpenFileDialogIn.ShowHelp = $true
- $textbox1.Text = Get-Content $OpenFileDialogIn.filename
- }
- $buttonIn_Click={
- #TODO: Place custom script here
- Get-FileLocImport
- }
Can any one help please?
Thanks.