I am writing an auto-updating function that reads the client version from XML and then after patching some files, an XMLTextWriter should update the client version, but when ever I try to create the TextWriter I am being told that the file is still in use even though I close the readers. What am I missing?
'pulling in reader from xml'
Dim clientReader As XmlReader = XmlReader.Create("launch.xml")
'Read the XML files to determine the server version'
clientReader.ReadToFollowing("serverURL")
Dim serverURL As String = clientReader.ReadElementContentAsString()
Dim serverXMLpath As String = serverURL & "Updater/serverInfo.xml"
Dim serverReader As XmlTextReader = New XmlTextReader(serverXMLpath)
serverReader.ReadToFollowing("serverVer")
Dim serverVer As Double = serverReader.ReadElementContentAsDouble()
'Read client XML to determine clientVersion'
clientReader.ReadToFollowing("clientVer")
Dim clientVer As Double = clientReader.ReadElementContentAsDouble()
'Determine what updates need to be downloaded'
serverReader.ReadToFollowing("totalUpdates")
Dim totalUpdates As Integer = serverReader.ReadElementContentAsInt()
'.....'
'files are downloaded and updated here'
'.....'
clientReader.Close()
serverReader.Close()
'change the client version!'
Dim clientWriter As New XmlTextWriter("launch.xml", System.Text.Encoding.UTF8)
'clientWriter.WriteElementString("clientVer", serverVer)