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. XML / XSL
  4. Reading and writing to an xml document

Reading and writing to an xml document

Scheduled Pinned Locked Moved XML / XSL
helpquestionxml
2 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.
  • S Offline
    S Offline
    steve_rm
    wrote on last edited by
    #1

    Hello, I am trying to read and write to a xml document into a dataset, but got an error message that cannot find the file path. This is using the Compact Framework 2.0, so cannot use the currentDirectory or startupPath, I have used the code below. However, the path i get is \programFile\PDACodeRedWM5 which is returned PDACodeRedWM5 being the name of my project. However, this path doesn't exist on my file system. So i got an error saying 'Could not find a part of the path '\C:\Program Files\PDACodeRedWM5\webServiceUrl.xml'. So i created this actual path on my file system and still got the same error message. This is my code so you can have a better understanding, I am trying to read in a xml file into a Dataset. Try 'File the xml file Dim fileName As String = String.Empty Dim ds As New DataSet Dim dv As DataView Dim path As String path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetModules(0).FullyQualifiedName) 'Read in the xml file fileName = String.Format("{0}\WebServiceURL.xml", path) ds.ReadXml(fileName) 'Find if a url already exists dv = New DataView(ds.Tables(0)) If (dv.Count = 0) Then 'This is the first time the application is running, so input from user Dim objInputURL As New InputURL() objInputURL.ShowDialog() Else 'Set the URL to the current web service location Dim objUrl As New Globals objUrl.UrlPath = ds.Tables(0).Rows(0)("url").ToString() End If Catch ex As Exception MsgBox(ex.Message) End Try If the programFile\PDACodeRedWM5 has not been created why does it give that file path? The actual path the application is in, is on my D drive. Many thanks for any help, Steve

    L 1 Reply Last reply
    0
    • S steve_rm

      Hello, I am trying to read and write to a xml document into a dataset, but got an error message that cannot find the file path. This is using the Compact Framework 2.0, so cannot use the currentDirectory or startupPath, I have used the code below. However, the path i get is \programFile\PDACodeRedWM5 which is returned PDACodeRedWM5 being the name of my project. However, this path doesn't exist on my file system. So i got an error saying 'Could not find a part of the path '\C:\Program Files\PDACodeRedWM5\webServiceUrl.xml'. So i created this actual path on my file system and still got the same error message. This is my code so you can have a better understanding, I am trying to read in a xml file into a Dataset. Try 'File the xml file Dim fileName As String = String.Empty Dim ds As New DataSet Dim dv As DataView Dim path As String path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetModules(0).FullyQualifiedName) 'Read in the xml file fileName = String.Format("{0}\WebServiceURL.xml", path) ds.ReadXml(fileName) 'Find if a url already exists dv = New DataView(ds.Tables(0)) If (dv.Count = 0) Then 'This is the first time the application is running, so input from user Dim objInputURL As New InputURL() objInputURL.ShowDialog() Else 'Set the URL to the current web service location Dim objUrl As New Globals objUrl.UrlPath = ds.Tables(0).Rows(0)("url").ToString() End If Catch ex As Exception MsgBox(ex.Message) End Try If the programFile\PDACodeRedWM5 has not been created why does it give that file path? The actual path the application is in, is on my D drive. Many thanks for any help, Steve

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Steve I am not sure I agree with you conclusion that an issue of finding a file using the compact framework qualifies as an XML issue just because the contents of your particular file is XML. Oh never mind... I just noticed you are using VB.

      led mike

      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