Groups | Blog | Home
all groups > dotnet windows forms > january 2007 >

dotnet windows forms : simple path problem


Patrick F
1/28/2007 4:11:01 AM
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("\\")

Jeff Gaines
1/28/2007 5:06:42 AM
On 28/01/2007 in message
[quoted text, click to view]

FileInfo fInfo = new FileInfo(c:\programs\myprogram\another
folder\program.exe);
string strFolder = fInfo.DirectoryName;

--
Patrick F
1/28/2007 5:21:02 AM
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

[quoted text, click to view]
Otis Mukinfus
1/28/2007 7:33:44 AM
On Sun, 28 Jan 2007 04:11:01 -0800, Patrick F
[quoted text, click to view]

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
Oliver Sturm
1/28/2007 1:09:05 PM
Hello Patrick,

[quoted text, click to view]

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



Oliver Sturm
--
Oliver Sturm
1/28/2007 4:08:11 PM
[quoted text, click to view]

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


Oliver Sturm
--
AddThis Social Bookmark Button