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. Visual Basic
  4. XML file not written in intended directory

XML file not written in intended directory

Scheduled Pinned Locked Moved Visual Basic
questionhelpcsharpdatabase
3 Posts 2 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.
  • P Offline
    P Offline
    Paul Hasler
    wrote on last edited by
    #1

    First off, please forgive me if this is in the wrong section. I'm not sure if the probelm is my VB.Net code or my understanding of installers. I've written a Windows Forms Application which stores it's preference settings in an XML file. I'm having problems with the file not being written to the directory I intend. I want to write the XML file in the application folder C:\Program Files\MyApplication, but when I install and then run my application it writes the XML file in C:\Users\MyAccount\AppData\Local\VirtualStore\Program Files\MyApplication (This folder does not contain a copy of the executable, and is empty apart from the files written by my application when it runs). I've made the following declarations in the application for the file name and path:

    Private strApplicationPath As String = Application.StartupPath
    Private strPreferencesFileName As String = "\Preferences.ini"

    I have my application preferences stored in a DataSet called dsPreferences, and use the following code to write the file:

    dsPreferences.WriteXml(strApplicationPath & strPreferencesFileName, XmlWriteMode.WriteSchema)

    To help me sort out what's going on I've also added a lable to the form called lblPath to display the file name and path:

    lblPath.Text = strApplicationPath & strPreferencesFileName

    When I do a Release Build, and run the executable everything seems to work fine. The XML file is written in the same directory as the executable ie C:\Projects\MyApplication\bin\Release and lblPath.Text also displays C:\Projects\MyApplication\bin\Release HOWEVER! I then use "Inno Setup 5" and "ISTool" to create an installer, and then install the application to C:\Program Files\MyApplication. Now when I run the application the XML file is written to C:\Users\MyAccount\AppData\Local\VirtualStore\Program Files\MyApplication instead of C:\Program Files\MyApplication where the executable is, even though lblPath.Text still shows that strApplicationPath & strPreferencesFileName = C:\Program Files\MyApplication !?! :confused: The same issue is happening with the SqlCe database file for the application. - What is this VirtualStore? - Why is the XML file written there when I've been reasonably explicit that it should be stored in the same folder as the executable? - How can I make sure the file gets written to th

    G 1 Reply Last reply
    0
    • P Paul Hasler

      First off, please forgive me if this is in the wrong section. I'm not sure if the probelm is my VB.Net code or my understanding of installers. I've written a Windows Forms Application which stores it's preference settings in an XML file. I'm having problems with the file not being written to the directory I intend. I want to write the XML file in the application folder C:\Program Files\MyApplication, but when I install and then run my application it writes the XML file in C:\Users\MyAccount\AppData\Local\VirtualStore\Program Files\MyApplication (This folder does not contain a copy of the executable, and is empty apart from the files written by my application when it runs). I've made the following declarations in the application for the file name and path:

      Private strApplicationPath As String = Application.StartupPath
      Private strPreferencesFileName As String = "\Preferences.ini"

      I have my application preferences stored in a DataSet called dsPreferences, and use the following code to write the file:

      dsPreferences.WriteXml(strApplicationPath & strPreferencesFileName, XmlWriteMode.WriteSchema)

      To help me sort out what's going on I've also added a lable to the form called lblPath to display the file name and path:

      lblPath.Text = strApplicationPath & strPreferencesFileName

      When I do a Release Build, and run the executable everything seems to work fine. The XML file is written in the same directory as the executable ie C:\Projects\MyApplication\bin\Release and lblPath.Text also displays C:\Projects\MyApplication\bin\Release HOWEVER! I then use "Inno Setup 5" and "ISTool" to create an installer, and then install the application to C:\Program Files\MyApplication. Now when I run the application the XML file is written to C:\Users\MyAccount\AppData\Local\VirtualStore\Program Files\MyApplication instead of C:\Program Files\MyApplication where the executable is, even though lblPath.Text still shows that strApplicationPath & strPreferencesFileName = C:\Program Files\MyApplication !?! :confused: The same issue is happening with the SqlCe database file for the application. - What is this VirtualStore? - Why is the XML file written there when I've been reasonably explicit that it should be stored in the same folder as the executable? - How can I make sure the file gets written to th

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      let me guess - you're running on Vista, right ? .. Im not a Vista pro, but I found this for example "An app that requires write access into program files sees c:\program files\MyApp\UserData, but it's really in c:\users\stephen\AppData\VirtualStore\Program Files\MyApp\UserData" Its a 'redirection'/security/UAC thing that Vista does Ive posted some links that [may] help http://social.msdn.microsoft.com/Forums/en-NZ/windowssecurity/thread/e85a62b7-d7c6-4d77-8b4c-11d5892b7218[^] http://www.itwriting.com/blog/141-peeking-into-vistas-virtual-store.html[^]

      P 1 Reply Last reply
      0
      • G Garth J Lancaster

        let me guess - you're running on Vista, right ? .. Im not a Vista pro, but I found this for example "An app that requires write access into program files sees c:\program files\MyApp\UserData, but it's really in c:\users\stephen\AppData\VirtualStore\Program Files\MyApp\UserData" Its a 'redirection'/security/UAC thing that Vista does Ive posted some links that [may] help http://social.msdn.microsoft.com/Forums/en-NZ/windowssecurity/thread/e85a62b7-d7c6-4d77-8b4c-11d5892b7218[^] http://www.itwriting.com/blog/141-peeking-into-vistas-virtual-store.html[^]

        P Offline
        P Offline
        Paul Hasler
        wrote on last edited by
        #3

        I think you hit the nail on the head there! Thanks! :thumbsup::thumbsup:

        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