Using PowerShell Studio 2019 64bit Version 5.6.167
Script Engine: PowerShell V5 Host (Windows Forms) - STA Enabled
All end users running Windows 10 or Windows 7 Enterprise.
I have a $folderbrowsermoderndialog1 with an InitialDirectory set to a network path \\server\share\folder. This path is variable depending on a selected combobox.
The app that this is in is deployed out to around 30 users who are using it on a daily basis. I had one user yesterday report that they cant access the share path after clicking to browse for a folder. The computer is running Windows 10 Enterprise.
The screenshot I got from the user looks to shows the folderbrowserdialog, not the modern version. Because of this, its not defaulting to the network path and they are unable to select the folder unless they go into Network > ServerName > Share > Folder manually.
This is what they see (redacted for confidentiality)
If they close the app and restart it, it works again correctly for a bit and then reverts back again. So far I haven't witnessed it myself so I dont know if there is any pattern to it but either way it doesn't make sense.
My understanding is this behavior should only happen if the OS is older than Windows 7.
Any ideas? I cant find anything in my searching thus far.
Thanks.
folderbrowsermoderndialog reverting to non modern on Win 10
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.
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: folderbrowsermoderndialog reverting to non modern on Win 10
This sounds more like a network issue. Do you know the exact error message when the user try to access the shared folder?
In the meantime, we'll be investigating and get back to you soon.
In the meantime, we'll be investigating and get back to you soon.
Re: folderbrowsermoderndialog reverting to non modern on Win 10
Thanks for the prompt response.
They don't receive any errors that i'm aware of (when I asked they said no), it just opens the folderbrowserdialog to the base "My Computer" location.
If you believe it may be a network connectivity issue, would it be useful to implement a test-path check prior to allowing the dialog to open so we can rule it out?
To provide more details, the application itself will not open if the user is not on the network and can reach the network share. Then they log on (security and logging purposes) and are able to do various functions such as move, copy and rename certain folders within the network share which are otherwise locked down outside of the app.
Although they get this dialog, they are still able to do the other functions to the network share and can still navigate to it via the manual way as outlined in my first post.
They don't receive any errors that i'm aware of (when I asked they said no), it just opens the folderbrowserdialog to the base "My Computer" location.
If you believe it may be a network connectivity issue, would it be useful to implement a test-path check prior to allowing the dialog to open so we can rule it out?
To provide more details, the application itself will not open if the user is not on the network and can reach the network share. Then they log on (security and logging purposes) and are able to do various functions such as move, copy and rename certain folders within the network share which are otherwise locked down outside of the app.
Although they get this dialog, they are still able to do the other functions to the network share and can still navigate to it via the manual way as outlined in my first post.
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: folderbrowsermoderndialog reverting to non modern on Win 10
Although we haven't reproduce the issue yet, if there's an issue with the network or even the user credentials, then by default the filebrowser will display the actual user folder list instead of giving an error.
So, for sure you may need to add the necessary code to catch the condition you're experiencing.
So, for sure you may need to add the necessary code to catch the condition you're experiencing.
Re: folderbrowsermoderndialog reverting to non modern on Win 10
With this dialog you must test the exisitence of the folder before using it or the problem you are seeing will happen. With shares and network resources the network may become unavailable. This is not a scripting issue and would require that you repair the issue when discovered.
To test the path just use "Test-Path" and report the failure and skip the showing the dialog.
Re: folderbrowsermoderndialog reverting to non modern on Win 10
It would be helpful if you posted a simplified version of yuour code so that we can see if there is a coding issue that might cause the path variable to be $null or contain a bad value.
Post the event and the other form code that manages the variable used to set the default.
The FolderBrowserDialog will always default this way when the path is either wrong OR null. This has noting to do with the "modern folder browser" dialog.
Post the event and the other form code that manages the variable used to set the default.
The FolderBrowserDialog will always default this way when the path is either wrong OR null. This has noting to do with the "modern folder browser" dialog.
Re: folderbrowsermoderndialog reverting to non modern on Win 10
Makes sense. The user in question is in the office though and the file share is on the local LAN which is always available. The chance though that its getting disconnected for a moment and reconnecting though is always a possibility. It may be that they are swapping to WiFi and the connection hiccups as well. The share paths available to the end user are static and do not change.
Here is a simplified version of the code.
I will implement the Test-Path check and display an error instead of showing the dialog to see how this goes. I'll get it pushed to the user on Monday and have them test.
Thanks for the help.
Here is a simplified version of the code.
Code: Select all
$buttonSelect_Click={
if ($comboboxMoveRegion.Text.Length -eq 0)
{
$labelMoveResult.ForeColor = 'Red'
$labelMoveResult.Text = "Error: Select a region first"
return
}
switch ($comboboxMoveRegion.Text)
{
"1. full name" {
$MoveRegionPath = "1. folder name"
}
"2. full name" {
$MoveRegionPath = "2. folder name"
}
}
$MoveRegionPath = "\\server\folder\$MoveRegionPath"
$folderbrowsermoderndialog1.InitialDirectory = $MoveRegionPath
if ($folderbrowsermoderndialog1.ShowDialog() -eq "OK")
{
$textboxFolder.Text = $folderbrowsermoderndialog1.SelectedPath
# below this there is other fields modified based on the selected path which is not relevant IMO
}
}
I will implement the Test-Path check and display an error instead of showing the dialog to see how this goes. I'll get it pushed to the user on Monday and have them test.
Thanks for the help.
Re: folderbrowsermoderndialog reverting to non modern on Win 10
Here is a simpler method for doing this:
If you load the ListBox with a collection of simple objects with the display name and the full path as properties then you can just do this.
To load the ComboBox with objects:
Code: Select all
$buttonSelect_Click = {
switch ($comboboxMoveRegion.SelectedItem) {
"1. full name" {
$MoveRegionPath = "1. folder name"
}
"2. full name" {
$MoveRegionPath = "2. folder name"
}
default {
$labelMoveResult.Text = "Error: Select a region first"
$labelMoveResult.ForeColor = 'Red'
return
}
}
$MoveRegionPath = "\\server\folder\$MoveRegionPath"
$folderbrowsermoderndialog1.InitialDirectory = $MoveRegionPath
if ($folderbrowsermoderndialog1.ShowDialog() -eq "OK") {
$textboxFolder.Text = $folderbrowsermoderndialog1.SelectedPath
# below this there is other fields modified based on the selected path which is not relevant IMO
}
}
Code: Select all
$buttonSelect_Click = {
if(Test-Path $comboboxMoveRegion.SelectedItem.FullPath){
if ($folderbrowsermoderndialog1.ShowDialog() -eq "OK") {
$folderbrowsermoderndialog1.InitialDirectory = $comboboxMoveRegion.SelectedItem.FullPath
$textboxFolder.Text = $folderbrowsermoderndialog1.SelectedPath
# below this there is other fields modified based on the selected path which is not relevant IMO
}
}else{
$labelMoveResult.Text = "Error: Path not found"
$labelMoveResult.ForeColor = 'Red'
}
}
Code: Select all
$form1_Load={
[System.Collections.ArrayList]@($paths =
[PsCustomObject]@{ RegionName = 'Name1'; FullPath = '\\server1\folder\folder' }
[PsCustomObject]@{ RegionName = 'Name2'; FullPath = '\\server2\folder\folder' }
[PsCustomObject]@{ RegionName = 'Name3'; FullPath = '\\server3\folder\folder' }
)
$comboboxMoveRegion.DataSource = $paths
$comboboxMoveRegion.DisplayMember = 'RegionName'
}
Re: folderbrowsermoderndialog reverting to non modern on Win 10
Hi jvierra, thanks for the improved code, this is great! I didn't realize that the combobox could be used in this way.
Re: folderbrowsermoderndialog reverting to non modern on Win 10
Yes. All controls with a "DataSource" can be assigned to objects, datatables or data binding controls and then they become the source for the objects being chosen or edited.