Results 1 to 3 of 3

Thread: [RESOLVED] Getting path of %AppData%

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Resolved [RESOLVED] Getting path of %AppData%

    Hello,

    I am using this code below:

    Code:
    dt.ReadXml("%AppData%\DateLinks.xml")
    However, I am getting an exception that point to the location of where my application is running from:

    Code:
    Could not find a part of the path 'D:\Projects\SubVersionProjects\CatDialer\bin\Debug\%AppData%\DateLinks.xml'.

    I thought the %AppData% should find the relative path. When I go 'Start|Run|%AppData% windows explorer takes me to that directory.

    I can not put the full path in, as the user is different on each client machine.

    Many thanks for any advice,
    steve

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Getting path of %AppData%

    That's an environment variable and ReadXml has no knowledge of environment variables. I believe that the Path class can expand environment variables for you but in this case just look at the Environment.GetFolderPath method.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: Getting path of %AppData%

    Thanks,

    vb Code:
    1. Dim path As String = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "DataLinks.xml")
    steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width