How to get current directory in C# for any Windows version?
- by DarthRoman
I am creating an application that can be executed in any windows version, even in mobile's, and I am trying to get the current directory of the executable.
The problem is that if I use the following code, it doesn't compile in Windows Mobile:
string currentDirectory = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
And if I use this code, I receive something like: file:\C:\xxx
string currentDirectory = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
Although, I need to get the root drive, and this code doesn't compile in Windows Mobile:
String rootPath = Path.GetPathRoot(Environment.SystemDirectory);
Does anyone know how to get the current directory of the application and the root path for any windows version, even mobile's?