Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2007

Tip: Looking for answers? Try searching our database.

simple path problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick F - 28 Jan 2007 12:11 GMT
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:\
Jeff Gaines - 28 Jan 2007 13:06 GMT
On 28/01/2007 in message

>How do you get the path to the folder the program is in.
>
[quoted text clipped - 9 lines]
>
>but that just returns c:\

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

Signature

Jeff Gaines

Patrick F - 28 Jan 2007 13:21 GMT
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

> On 28/01/2007 in message
>
[quoted text clipped - 15 lines]
> folder\program.exe);
> string strFolder = fInfo.DirectoryName;
Oliver Sturm - 28 Jan 2007 13:09 GMT
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
Signature

http://www.sturmnet.org/blog

Otis Mukinfus - 28 Jan 2007 13:33 GMT
>How do you get the path to the folder the program is in.
>
[quoted text clipped - 9 lines]
>
>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
Oliver Sturm - 28 Jan 2007 16:08 GMT
>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
Signature

http://www.sturmnet.org/blog


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.