Sign in to follow this  

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

This topic is 4839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this