How to get the application data folder for each user ?
-
Hi I am writing a small program , I need to find the application data folder which exists in c:\documents and settings folder. I need to know the exact path, if the user has installed the windows in d:\ then it should look at d:\. Even if I could know the windows installation drive then I think it would help ? I got some code in VB but i cannot use it in csharp . Any suggestions would be appreciated. //************************************************************ Public Function GetTheWindowsDirectory() As String Dim strWindowsDir As String ' Variable to return the path of Windows Directory Dim lngWindowsDirLength As Long ' Variable to return the the lenght of the path strWindowsDir = Space(250) ' Initilize the buffer to receive the string lngWindowsDirLength = GetWindowsDirectory(strWindowsDir, 250) ' Read the path of 'the windows directory strWindowsDir = Left(strWindowsDir, lngWindowsDirLength) ' Extract the windows 'path from the buffer GetTheWindowsDirectory = strWindowsDir //********************************************* The above is the code for vb.net Thanks
-
Hi I am writing a small program , I need to find the application data folder which exists in c:\documents and settings folder. I need to know the exact path, if the user has installed the windows in d:\ then it should look at d:\. Even if I could know the windows installation drive then I think it would help ? I got some code in VB but i cannot use it in csharp . Any suggestions would be appreciated. //************************************************************ Public Function GetTheWindowsDirectory() As String Dim strWindowsDir As String ' Variable to return the path of Windows Directory Dim lngWindowsDirLength As Long ' Variable to return the the lenght of the path strWindowsDir = Space(250) ' Initilize the buffer to receive the string lngWindowsDirLength = GetWindowsDirectory(strWindowsDir, 250) ' Read the path of 'the windows directory strWindowsDir = Left(strWindowsDir, lngWindowsDirLength) ' Extract the windows 'path from the buffer GetTheWindowsDirectory = strWindowsDir //********************************************* The above is the code for vb.net Thanks
-
Hi I am writing a small program , I need to find the application data folder which exists in c:\documents and settings folder. I need to know the exact path, if the user has installed the windows in d:\ then it should look at d:\. Even if I could know the windows installation drive then I think it would help ? I got some code in VB but i cannot use it in csharp . Any suggestions would be appreciated. //************************************************************ Public Function GetTheWindowsDirectory() As String Dim strWindowsDir As String ' Variable to return the path of Windows Directory Dim lngWindowsDirLength As Long ' Variable to return the the lenght of the path strWindowsDir = Space(250) ' Initilize the buffer to receive the string lngWindowsDirLength = GetWindowsDirectory(strWindowsDir, 250) ' Read the path of 'the windows directory strWindowsDir = Left(strWindowsDir, lngWindowsDirLength) ' Extract the windows 'path from the buffer GetTheWindowsDirectory = strWindowsDir //********************************************* The above is the code for vb.net Thanks
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
-
Hi I am writing a small program , I need to find the application data folder which exists in c:\documents and settings folder. I need to know the exact path, if the user has installed the windows in d:\ then it should look at d:\. Even if I could know the windows installation drive then I think it would help ? I got some code in VB but i cannot use it in csharp . Any suggestions would be appreciated. //************************************************************ Public Function GetTheWindowsDirectory() As String Dim strWindowsDir As String ' Variable to return the path of Windows Directory Dim lngWindowsDirLength As Long ' Variable to return the the lenght of the path strWindowsDir = Space(250) ' Initilize the buffer to receive the string lngWindowsDirLength = GetWindowsDirectory(strWindowsDir, 250) ' Read the path of 'the windows directory strWindowsDir = Left(strWindowsDir, lngWindowsDirLength) ' Extract the windows 'path from the buffer GetTheWindowsDirectory = strWindowsDir //********************************************* The above is the code for vb.net Thanks
The APPDATA environment variable.
string filename = System.Environment.ExpandEnvironmentVariables ( "%APPDATA%\\myfile.txt" ) ;
(If I recall correctly.)