Results 1 to 4 of 4

Thread: Saving to virtual store in Windows 7

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    165

    Saving to virtual store in Windows 7

    Testing out a VB.net prog in Windows 7 that works ok in Vista and earlier. The users can set various options and save them for next time. In pre Vista this goes in the program directory in program files, in Vista it is transparently put into the user's virtual store.

    However, in Windows 7 trying to save the file gives an access denied error although the virtual store exists as for Vista and other apps appear to be using it ok. This is a program for schools and having to run the program as admin, if that would help anyway, is not an option. Anyone else had a problem with this?

    Thanks for any suggestions.

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

    Re: Saving to virtual store in Windows 7

    The answer is to not save your file to the program folder. Windows has had an application data folder for a long time, before Vista started actually preventing you from saving to the program folder. You can use Environment.GetFolderPath or My.Computer.FileSystem.SpecialDirectories to get numerous standard folder paths, including the application data folder.
    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
    Addicted Member
    Join Date
    May 2007
    Posts
    165

    Re: Saving to virtual store in Windows 7

    Using specialdirectories to present My Documents as default path looks good. Thanks very much for your help.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    165

    Re: Saving to virtual store in Windows 7

    For anyone else with same problem the best option is probably:

    My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData

    see:

    http://msdn.microsoft.com/en-us/libr...db(VS.80).aspx

    You set the path in project application/assembly information. You may still need to handle exception and set another path if does not exist for older versions of windows.

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