How can I get the folder in which a C# WinForms executable file is located?
My program generates some temporary files and I am wondering if the location of the executable is a safe location to place them.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If the files are just temp files, you should probably be using the following:
That will give you the current user’s temp folder. This is probably a safer bet then trying to write them into the exe’s current folder.
More Info: http://msdn.microsoft.com/en-us/library/system.io.path.gettemppath.aspx