i am trying to read an xml file and a txt file using one button click i currently have this code in my button, i don't know what it is that i'm doing wrong any help or advice of sort would be great.
try
{
XmlReader file;
file = XmlReader.Create("c:/CSAIO4D/BK01/CH01/ReadFiles/ReadFiles/XMLFile1.xml", new XmlReaderSettings());
DataSet ds = new DataSet();
ds.ReadXml(file);
dataGridView1.DataSource = ds.Tables[0];
StreamReader files = new StreamReader("c:/CSAIO4D/BK01/CH01/ReadFiles/ReadFiles/People.txt");
string[] columnnames = files.ReadLine().Split(',');
DataTable dt = new DataTable();
foreach (string c in columnnames)
{
dt.Columns.Add(c);
}
string newline;
while ((newline = files.ReadLine()) != null)
{
DataRow dr = dt.NewRow();
string[] values = newline.Split(',');
for (int i = 0; i < values.Length; i++)
{
dr[i] = values[i];
}
dt.Rows.Add(dr);
}
file.Close();
dataGridView1.DataSource = dt;
dataGridView1.Visible = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
can someone please help me out, i am new to web forms, the issue that i am having is that it only reads the text file and return it to the DataGridView and does not read the xml