In Windows Application programming, many developers create the log file in the app directory which is not always available to a regular user and its not a good idea.
The log file should probably go in the AppData folder i.e. %appdata% as long as it can be opened from the application.
Here is the source code to get path of appdata folder then you can create another directory under the appfolder:
C# code:
// The folder for the roaming current user
string appDataFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
// Combine the base folder with your specific i.e. application folder....
string specificFolder = System.IO.Path.Combine(appDataFolder ,[ApplicationFolderName]);
VB.Net code:
' The folder for the roaming current user
Dim appDataFolder As String = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData)
' Combine the base folder with your specific i.e. application folder....
Dim specificFolder As String = System.IO.Path.Combine(appDataFolder,(ApplicationFolderName))
Happy Coding!!
0 Comment(s)