C# Get true path of current directory
19,183
Solution 1
Directory Of Base Assembly Resolver:
AppDomain.CurrentDomain.BaseDirectory;
Solution 2
The safest way:
string temp = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
Solution 3
To map a page (or Virtual Directory) to the filesystem location (at runtime) you can user Server.MapPath("/")
Solution 4
Use:
Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
Author by
Novak
Updated on June 14, 2022Comments
-
Novak almost 2 years
I have a project, built with Visual Web Developer 2008. I want to be able to extract (with C#), the current folder the project is in now. Until now I had to hard code the true path.
This project is hosted on my computer.
For example, the path I would like to generate:
C:\Users\Guy\Desktop\Project
Thanks! Guy