My project name ImageProfiler. My project is in the drive C: then how can i get the path of my project.. the output looks like this "C:\ImageProfil er"
How can i get the current directory of Project folder?
Collapse
X
-
Tags: None
-
I don't know why you need your project path, usually what people ned is the path to the directory where currently executing .exe file is. You do it like this:
Then, I suppose to get your project directory, you'll need to call Directory.GetPa rent() a few times (depending on your project's file structure).Code:string dirname = Directory.GetCurrentDirectory();
Other ways to find your exe directory are:
for Form applications andCode:string appPath = Path.GetDirectoryName(Application.ExecutablePath);
for loaded assemblies (.exe, .dll).Code:string path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(MyClass)).CodeBase);
You'll need to add certain references to your project to use those, like:
Code:using System.IO; using System.Reflection;//in the lase example
Comment