$openfiledialog1.InitialDirectory = "C:\Download\cert"
$openfiledialog1.Filter = "Config|*.cfg"
if ($openfiledialog1.ShowDialog() -eq 'OK')
{
$SelectedPath = $openfiledialog1.FileName
Ive used several hard coded attempt but when running it opens in the same folder as my exe not where I specify any ideas?
When
To help you better we need some information from you.
*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***
Product, version and build:pSS 2019 current build
32 or 64 bit version of product:64
Operating system:win 10 1607
32 or 64 bit OS: win 10 64bit
*** Please add details and screenshots as needed below. ***
DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
$openfiledialog1.InitialDirectory not opening in correct folder
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- ocsscott6969
- Posts: 48
- Last visit: Tue Dec 05, 2023 10:04 am
Re: $openfiledialog1.InitialDirectory not opening in correct folder
[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: $openfiledialog1.InitialDirectory not opening in correct folder
I ran a quick test and the dialog opens to the correct path when I set the InitialDirectory property.
Does the specified folder exist? If not, it might default to another path.
Does the specified folder exist? If not, it might default to another path.
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- ocsscott6969
- Posts: 48
- Last visit: Tue Dec 05, 2023 10:04 am
Re: $openfiledialog1.InitialDirectory not opening in correct folder
yes it does but I am displaying it and it looks like this
Microsoft.powershell.core\filesystem:\\The correct path
is the Microsoft.powershell.core\filesystem:\\ causing the issue?
Microsoft.powershell.core\filesystem:\\The correct path
is the Microsoft.powershell.core\filesystem:\\ causing the issue?
Re: $openfiledialog1.InitialDirectory not opening in correct folder
Yes, that will cause the problem. You will have to trim that portion out.
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- ocsscott6969
- Posts: 48
- Last visit: Tue Dec 05, 2023 10:04 am
Re: $openfiledialog1.InitialDirectory not opening in correct folder
fyi I am getting the path with this code
$A = Get-Location
$global:LocalPath = $A.path.ToString()
to find where my exe is running then + "\subfolder" for the open location
is something wrong with that?
$A = Get-Location
$global:LocalPath = $A.path.ToString()
to find where my exe is running then + "\subfolder" for the open location
is something wrong with that?
Re: $openfiledialog1.InitialDirectory not opening in correct folder
Get-Location will only give you the working directory which isn't necessarily the directory of the executable.
I recommend using the either:
Get-ScriptDirectory function (snippet: getscriptdirectory)
Or if you are using the latest version of PowerShell Studio 2019, the $PSScriptRoot variable.
I recommend using the either:
Get-ScriptDirectory function (snippet: getscriptdirectory)
Or if you are using the latest version of PowerShell Studio 2019, the $PSScriptRoot variable.
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- ocsscott6969
- Posts: 48
- Last visit: Tue Dec 05, 2023 10:04 am
Re: $openfiledialog1.InitialDirectory not opening in correct folder
that worked much better and allowed the open dialog to work as expected.
Much thanks
Much thanks