tags:

views:

66

answers:

3

I currently store my log file in the Program Files\My App folder but some users don't have permission to write here if they are not a power user or administrator. Is there a common location for this type of log file?

Thanks

A: 

Forgot to say that I'm currently using Application.StartupPath.

logFileLocation = System.Windows.Forms.Application.StartupPath;

Thanks

Jason, you can edit your question to include this info ;o)
wcm
A: 

I would use the temporary folder.

Use the function GetTempPath on the Windows API, or Path.GetTempPath in .NET

John Sibly
By definition, the temporary folder is where you store temporary, throw-away files that are supposed to be deletable at any time.Depending on whether the log file is supposed to be kept across sessions or not, it may not be a good choice to put it there...
RaphaelSP
+3  A: 

I'd use Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) and then Path.Combine that with ApplicationName\Version\LogFileName

Will
AFAIK, this will work only if the user that creates the file is the only one who needs to write to it. If multiple users need to write the file, then "Common App Data" is the best place, but you must use a service to manage file access.
Nicolas
From MSDN: "CommonApplicationData: The directory that serves as a common repository for application-specific data that is used by all users."
Will