Hello, I'm making a program, and on start up I have so it searches for XML files in a folder, then add the values from each file to a datagrid. Now my problem is that if an XML file happens to be empty my program can't find the nodes and will then crash.
So how can I make it first check if the file actually has the nodes, and if it doesn't, then just skip it.
Here is my code:
Thanks.
So how can I make it first check if the file actually has the nodes, and if it doesn't, then just skip it.
Here is my code:
VB.NET:
Dim files() As String = Directory.GetFiles(Application.StartupPath + "\data\lyrics\", "*.xml")
Dim rowc As Integer = 0
For Each FILE_NAME As String In files
ds.ReadXml(FILE_NAME)
dg.DataSource = ds
dg.DataMember = "Song"
dg.Columns(3).Visible = False
dg.Columns(4).Visible = False
dg.Columns(5).Visible = False
dg.Rows.Item(rowc).Cells.Item(5).Value = FILE_NAME
rowc += 1
Next
Thanks.