[ACCEPTED]-Environment.CurrentDirectory in C#.NET-c#-3.0
set current directory
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); //or set executing Assembly location path in param
Environment.CurrentDirectory //now returns your app path
0
Use
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
0
You shouldn't be using the Environment.CurrentDirectory 9 value as a base for file lookups because 8 it can change and may not always be under 7 your control. e.g. a File Save As to a different 6 folder may change the 'current folder' value. As 5 you can see it can yield unpredictable results.
Use 4 a value that you can control better. e.g. a 3 ResourcesFolderPath value in a configuration 2 (xml?) file that is updated when you install 1 your app.
I suspect that this could have something 7 to do with the current user id that the 6 app is running under, for example if you 5 are running the app in a user session (e.g. debugging 4 in VS) then this may return your current 3 directory, but if you were running it under 2 IIS then this could be why it is defaulting 1 to the system folder?
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.