Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to get the application data folder for each user ?

How to get the application data folder for each user ?

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 3950922
    wrote on last edited by
    #1

    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

    A U P 3 Replies Last reply
    0
    • U User 3950922

      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

      A Offline
      A Offline
      Alan N
      wrote on last edited by
      #2

      Hi, The Environment class in the System namespace contains methods to get all of this info. The GetFolderPath method is especially useful. Alan

      1 Reply Last reply
      0
      • U User 3950922

        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

        U Offline
        U Offline
        User 3950922
        wrote on last edited by
        #3

        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

        1 Reply Last reply
        0
        • U User 3950922

          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

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          The APPDATA environment variable. string filename = System.Environment.ExpandEnvironmentVariables ( "%APPDATA%\\myfile.txt" ) ; (If I recall correctly.)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups