simple path problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do you get the path to the folder the program is in.

Lets say i have something like this:

c:\programs\myprogram\another folder\program.exe

now in my program i want to get the path,
c:\programs\myprogram\another folder\

I tried something like:
System.IO.Path.GetFullPath("\\")

but that just returns c:\
 
How do you get the path to the folder the program is in.

Lets say i have something like this:

c:\programs\myprogram\another folder\program.exe

now in my program i want to get the path,
c:\programs\myprogram\another folder\

I tried something like:
System.IO.Path.GetFullPath("\\")

but that just returns c:\

FileInfo fInfo = new FileInfo(c:\programs\myprogram\another
folder\program.exe);
string strFolder = fInfo.DirectoryName;
 
Hello Patrick,
I tried something like:
System.IO.Path.GetFullPath("\\")

but that just returns c:\

You should be fine using Path.GetDirectoryName() for your purpose.



Oliver Sturm
 
its not what i am after, i dont know the path. the user takes the program and
put it into a "for me unknown" path on his computer and i need to get the
correct path c:\..... or f:\...
etc
 
How do you get the path to the folder the program is in.

Lets say i have something like this:

c:\programs\myprogram\another folder\program.exe

now in my program i want to get the path,
c:\programs\myprogram\another folder\

I tried something like:
System.IO.Path.GetFullPath("\\")

but that just returns c:\

If you are trying to get the path of your executable application you should use
:

string path = Application.ExecutablePath;


Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 
If you are trying to get the path of your executable application you
should use
:

string path = Application.ExecutablePath;

Ah :-) I wouldn't have interpreted the OP's question this way, but now I
think this is probably the right answer!


Oliver Sturm
 
Back
Top