[.net] .NET System.Environment.CurrentDirectory Bug?

Started by
3 comments, last by Geronimo2000 19 years, 7 months ago
I doubt it's a bug, but I wanted to share this with other .NET programmers. Upon closing an OpenFileDialog control, the System.Environment.CurrentDirectory setting changes to the file I specified. This might be somewhat useful under certain circumstances, but it's particularly damning in my project. 1. Is this documented? 2 Should I be using another environment variable rather than resetting this variable upon closing the OpenFileDialog?
Advertisement
This is normal behavior. It would be best to store the current directory seperately if you require it to be remembered.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

I don't believe this is a bug. After all, how do you think the dialog "remembers" what directory was opened last in the dialog itself?

As for using a different variable, what value are you wanting to get? For instance, you can use either Application.StartUp path or Assembly.GetExecutingAssembly().Location. These are *not* the same value. It depends on what directory you want to get.
Jason Olson - Software Developer[ Managed World ]
Set the OpenFileDialog's RestoreDirectory property to true.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
Yes, I see it's not a bug at all... When I last set the ResetCurrentDirectory property, I erroneously believed it was related to the dialog's InitialDirectory property, which of course it is not.

My apologies for the stupid post. This is obviously NOT a bug.

This topic is closed to new replies.

Advertisement