PC Review


Reply
Thread Tools Rate Thread

simple path problem

 
 
=?Utf-8?B?UGF0cmljayBG?=
Guest
Posts: n/a
 
      28th Jan 2007
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:\
 
Reply With Quote
 
 
 
 
Jeff Gaines
Guest
Posts: n/a
 
      28th Jan 2007
On 28/01/2007 in message
<EFC44928-5EBD-4795-9A2F-(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Oliver Sturm
Guest
Posts: n/a
 
      28th Jan 2007
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
--
http://www.sturmnet.org/blog
 
Reply With Quote
 
=?Utf-8?B?UGF0cmljayBG?=
Guest
Posts: n/a
 
      28th Jan 2007
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

"Jeff Gaines" wrote:

> On 28/01/2007 in message
> <EFC44928-5EBD-4795-9A2F-(E-Mail Removed)> 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
>

 
Reply With Quote
 
Otis Mukinfus
Guest
Posts: n/a
 
      28th Jan 2007
On Sun, 28 Jan 2007 04:11:01 -0800, Patrick F
<(E-Mail Removed)> 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:\


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
 
Reply With Quote
 
Oliver Sturm
Guest
Posts: n/a
 
      28th Jan 2007
>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
--
http://www.sturmnet.org/blog
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to judge whether a path is relative path or absolute path thinktwice Microsoft Windows 2000 CMD Promt 20 7th May 2008 11:06 PM
Simple questions for simple 2 PC file sharing network. Simple? raylopez99 Microsoft Windows 2000 Networking 3 11th Feb 2007 02:31 PM
set path, change path - path grayed out John Smith Windows XP Help 1 12th Feb 2005 02:56 PM
set path, change path - path grayed out John Smith Windows XP General 1 12th Feb 2005 02:56 PM
Simple Simple Simple craigwojo Microsoft Excel New Users 3 29th Aug 2004 05:32 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:38 AM.