The property Environment.CurrentDirectory
always returns the path of system directory instead my application directory. In my colleague's PC, it returns application directory.
What is the problem? How can I solve it?
The following code is working for me
ePCRSettings = XMLParser.XmlParser.Deserialize<PCRGeneratorSettings>(string.Format("{0}\\ePCRPDFSettings.xml", AppDomain.CurrentDomain.BaseDirectory));
AppDomain.CurrentDomain.BaseDirectory - Returns the directory E:\MyApplications\.
The following code is not working for me
ePCRSettings = XMLParser.XmlParser.Deserialize<PCRGeneratorSettings>(string.Format("{0}\\ePCRPDFSettings.xml", Environment.CurrentDirectory));
Environment.CurrentDirectory - Returns c:\windows\system32.
This .dll file can be used in VB 6 and ASP.NET applications
open System open System.IO if Environment. OSVersion. Platform = PlatformID. Win32NT then // Change the directory to %WINDIR% Environment.
For example, if the prompt was "C:\Windows\System32>" the "System32" directory is the current directory, "Windows" is the parent directory, and "C:\" is the drive (root directory). To list the files in the current directory use the dir command, and if you want to change the current directory, use the cd command.
set current directory
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); //or set executing Assembly location path in param
Environment.CurrentDirectory //now returns your app path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With