Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

application directory??

Status
Not open for further replies.

gorgor

Programmer
Aug 15, 2002
164
US
(C# and .NET framework)

How do you get the application's directory? I'm trying to get the actual location of the executable. I need to write some temp files in the same directory where the application resides, but I want the location of the application's executable to be dynamic.

Thanks in advance.
 
// Get Application Information
//////////////////////////////////
Process p = Process.GetCurrentProcess();
string appName = p.ProcessName;
string appVersion = p.MainModule.FileVersionInfo.ProductVersion;
string appPath = Path.GetDirectoryName(p.MainModule.FileName);

For UNC path you should do more work.

-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top