Home All Groups Group Topic Archive Search About

Obtain the folder where is the executable of my application

Author
5 Sep 2006 3:26 PM
eduwushu
I want to obtain programatically the folder where the executable of my
applicationj is installed. I want that path to find other files which are
located related to the path where my application is installed. Is there
antway to do this?
For example i want to create a fileinfo object to retrieve the info of a
file which is in the same folder as the executable of my application. I have
tried to do this:

FileInfo info=new FileInfo(".\\example.txt");

the problem with this is that when i create a FileInfo object passing an
absolute path in its constructor

FileInfo info=new FileInfo("c:\\Program Files\\Folder\\File.txt");

when i try later to create another fileinfo object to get another file in
the same folder as my application executable

FileInfo info=new FileInfo(".\\anotherexample.txt"); it throws me an
exception because it cannot find "c:\Program Files\Folder\anotherExample.txt";

Author
5 Sep 2006 3:50 PM
Vadym Stetsyak
Hello, eduwushu!

System.Reflection.Assembly.GetEntryAssembly().Location

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Author
7 Sep 2006 1:11 PM
Ben Voigt
"Vadym Stetsyak" <vady***@ukr.net> wrote in message
news:ulAgJKQ0GHA.772@TK2MSFTNGP05.phx.gbl...
> Hello, eduwushu!
>
> System.Reflection.Assembly.GetEntryAssembly().Location

and
Directory.SetCurrentDirectory


Show quote
>
> --
> Regards, Vadym Stetsyak
> www: http://vadmyst.blogspot.com

AddThis Social Bookmark Button