File Path

H

Hoop

Hi,
I have a c# app that will create and save a few files. I will not know
the directory name where the app will be installed. I would like the
files that the app creates to be in the installed directory.
I do I get the path where the app will be located?
Thanks
Jeff
 
A

Arne Vajhøj

Hoop said:
I have a c# app that will create and save a few files. I will not know
the directory name where the app will be installed. I would like the
files that the app creates to be in the installed directory.
I do I get the path where the app will be located?

Path.GetDirectoryName(Environment.GetCommandLineArgs()[0])

Arne
 
J

Josh Einstein

It's worth noting that this is not a recommended practice, as typically the
application will be installed to a location where the user does not have
permissions to write files. Either because they are a non-admin on XP or
have UAC on under Vista.

If the files you're creating are intended to be seen/manipulated by the
user, you can put them in a directory under My Documents
(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) or if
they are just for the application's use, you can put them in a directory
under AppData
(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData).

Josh Einstein
 
H

Hoop

Hi,
I have a c# app that will create and save a few files. I will not know
the directory name where the app will be installed. I would like the
files that the app creates to be in the installed directory.
I do I get the path where the app will be located?
Thanks
Jeff



Hi,
Thanks for the quick answers. These all will help alot.
Jeff
 

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