I'm supporting an old version of a C# application, running on .NET 3.5. We've found an issue with the FolderBrowserDialog
on Windows Vista (either 32 or 64-bit).
Basically what happened is that the dialog would appear, but only the root Desktop node would be shown, not even able to expand it to show anything else. Obviously, that's impossible to use.
After a huge amount of trial and error I eventually managed to get something useable, by setting the RootFolder
property before the rest of the setup:
FolderBrowserDialog browsePath = new FolderBrowserDialog();
browsePath.RootFolder = Environment.SpecialFolder.MyComputer;
browsePath.SelectedPath = this.textBoxTo.Text;
browsePath.Description = TextResources.OutputTargetCaption;
browsePath.ShowNewFolderButton = true;
if(browsePath.ShowDialog(this) == DialogResult.OK)
{
this.textBoxTo.Text = UpdateLocation(browsePath.SelectedPath);
}
This almost works; however, I've got the bizarre issue that then the SelectedPath
(by definition the contents of textBoxTo
) is a path to within the current user's home directory, it won't automatically browse to that path, instead just showing the My Computer node expanded to one level. It's perfectly fine for any other path.
I'm sure your first guess would be a permissions issue, as was my intuition. It doesn't appear to be, this issue occurs running normally and as an Administrator, for both standard and Administrator accounts. It's a clean install, of course, no weird permissions or anything.
This is pretty annoying when all of our defaults are within the current user's directory!
Note: This only happens within the application; it's not reproducible with a small test application, as far as I've seen.
Any ideas on what could be causing this?
Update: Screenies:
This is the behaviour I want (obtainted from a little test app)
This is what I get with the default property
This is what I get by setting the root to My Computer
Note: The last image had the same SelectedPath
set as the expected image...
RootFolder
it will browse anything...Desktop golder it self is not expandable. Would be nice to see some screenshots from your application. – BanasRootFolder
. Sure, I'll grab some of the expected and current behaviour. – WoollyFolderBrowserDialog
? – OutdareSystem.Windows.Forms.FolderBrowserDialog
. – WoollySTAThread
as an attribte for yourMain
class?! – Banas