|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
simple path problemHow 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:\ On 28/01/2007 in message
<EFC44928-5EBD-4795-9A2F-86885748F***@microsoft.com> Patrick F wrote: >How do you get the path to the folder the program is in. FileInfo fInfo = new FileInfo(c:\programs\myprogram\another > >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:\ folder\program.exe); string strFolder = fInfo.DirectoryName; -- Jeff Gaines 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 Show quoteHide quote "Jeff Gaines" wrote: > On 28/01/2007 in message > <EFC44928-5EBD-4795-9A2F-86885748F***@microsoft.com> Patrick F wrote: > > >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; > > -- > Jeff Gaines > Hello Patrick,
>I tried something like: You should be fine using Path.GetDirectoryName() for your purpose.>System.IO.Path.GetFullPath("\\") > >but that just returns c:\ Oliver Sturm On Sun, 28 Jan 2007 04:11:01 -0800, Patrick F
<Patri***@discussions.microsoft.com> wrote: >How do you get the path to the folder the program is in. If you are trying to get the path of your executable application you should use> >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:\ : string path = Application.ExecutablePath;Good luck with your project, Otis Mukinfus http://www.arltex.com http://www.tomchilders.com
Other interesting topics
Non-proportional (non Rectangular) resizing
Asynchronous Programming Model - how to implement? How to Create WinForms client and ClassLib server as one assembly? Starting from .... DirectoryInfo - How To Get Name in Proper Case? ComboBox updating data source via look-up table Studio 2005 and the ".Designer" file...?!? Code practice in properties. Composite UI Application Block - Thread Safe Strange concurrency error Textbox copy and paste problem |
|||||||||||||||||||||||