.NET Questions (CLOSED)

Questions and Answers on any aspect of .NET. Now closed.

This discussion group is now closed.

Have a question about .NET development? Try stackoverflow.com, a worldwide community of great developers asking and answering questions 24 hours a day.

The archives of .NET Questions contain years of Q&A. Even older .NET Questions are still online, too.

C# Directory question

Hello, is there a way to know the directory where the program is at?

For example, with my program I must distribute an external folder with documents.

And in the program I need to know where the program is, so I can know where the folder is.

For example:

c:\download_software\MyProgram\program.exe
c:\download_software\MyProgram\FolderWithDocuments

vs

c:\Programs\MyProgram\program.exe
c:\Programs\MyProgram\FolderWithDocuments

So how do I know from C# where the program.exe is at, so the application is more flexible in terms of directories.

Thanks.
KrazyMane
Monday, November 12, 2007
 
 
Application.StartupPath.

But keep in mind that you typically can't create files under that directory if it is under "c:\Program Files" unless you have admin privileges. So what I do is have all of my support files like bitmaps and such under the program directory. And then configuraton, settings, and log files get created under the appropriate user directory using:

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

The path above is common to all users of the machine. If I want to have a user-specific folder I would use:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
anon
Wednesday, November 14, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz