-
xml file count help
I have over 4,000 xml files that needs to be converted in to a character based on a value and entered in to a rich text box. It will do this, until it runs out of files to read. I have tried "try" statements, "if" statements... I can't figure out how to fix the issue. I searched the forums with no results. Kinda makes me feel special :)
Code:
Imports System.Xml
Imports System.IO
Imports System
Imports Microsoft.VisualBasic
Public Class frmNavigation
Public m_Xcoord As String
Public m_Ycoord As String
Public m_ResourceValue As String
Public m_MResource As String
Public m_RResource As String
Dim xmlDirectory As String = "C:\Users\Josh\Documents\Visual Studio 2010\Projects\xmlCreator\xmlCreator\bin\Debug\worlds\glation"
Dim xmlFile As String = "C:\Users\Josh\Documents\Visual Studio 2010\Projects\xmlCreator\xmlCreator\bin\Debug\worlds\glation\glation"
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
Dim TempFile As String = "C:\Users\Josh\Documents\Visual Studio 2010\Projects\xmlCreator\xmlCreator\bin\Debug\worlds\glation\glation1.xml"
Dim Reader As Xml.XmlReader
Dim NewYcoord As String = "1"
Dim xmlFileCount As String = "0"
System.IO.Directory.SetCurrentDirectory(xmlDirectory)
Reader = Xml.XmlReader.Create(TempFile)
Do Until Reader.EOF = True
xmlFileCount = xmlFileCount + 1
xmlFile = xmlFile & xmlFileCount & ".xml"
If File.Exists(xmlFile) Then
Reader = Xml.XmlReader.Create(xmlFile)
Reader.ReadToFollowing("Xcoord")
m_Xcoord = Reader.ReadElementString("Xcoord")
m_Ycoord = Reader.ReadElementString("Ycoord")
Reader.ReadToFollowing("Resource")
m_ResourceValue = Reader.ReadElementString("Resource")
m_MResource = Reader.ReadElementString("Mountain")
m_RResource = Reader.ReadElementString("River")
xmlFile = "C:\Users\Josh\Documents\Visual Studio 2010\Projects\xmlCreator\xmlCreator\bin\Debug\worlds\glation\glation"
If m_Xcoord = 110 Then
NewYcoord = NewYcoord + 1
End If
If NewYcoord > m_Ycoord Then
rtbViewMap.Text = rtbViewMap.Text & vbCrLf
End If
If m_ResourceValue = "300" Then
rtbViewMap.Text = rtbViewMap.Text & "#"
ElseIf m_ResourceValue = "200" Then
rtbViewMap.Text = rtbViewMap.Text & "."
ElseIf m_ResourceValue = "100" Then
rtbViewMap.Text = rtbViewMap.Text & ";"
ElseIf m_ResourceValue = "0" And m_MResource = "0" And m_RResource = "0" Then
rtbViewMap.Text = rtbViewMap.Text & "%"
ElseIf m_MResource = "150" And m_RResource = "0" Then
rtbViewMap.Text = rtbViewMap.Text & "^"
ElseIf m_RResource = "70" And m_MResource = "0" Then
rtbViewMap.Text = rtbViewMap.Text & "~"
End If
End If
Loop
End Sub
End Class
-
Re: xml file count help
i don't understand the question... what doesn't happen that should happen?
-
Re: xml file count help
It should reach the last file in the directory and then stop, but instead it looks for another file and causes an error.