Obtain the folder where is the executable of my application

G

Guest

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";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top