DataTable
에 XML 파일을 읽는 데 문제가 있습니다. 처음에는 Datatable
을 XML 파일에 쓰고 저장했습니다. 이제 XML 파일을 DataTable
으로 다시 읽으려는 시도가 없습니다.DataTable을 XML 파일로 변환하고 viceversa
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (myDT_For_DGV.Rows.Count != 0)
{
saveFileDialog1.ShowDialog();
saveFileDialog1.FileName = "checkOutFile.xml";
myDT_For_DGV.TableName = "CheckOutsAndIns";
myDT_For_DGV.WriteXml(saveFileDialog1.FileName, true);
}
else
{
MessageBox.Show("Please add licences to DataGridView, you havent added any licences as of now", "Alert");
}
}
그리고 파일을 읽기 위해 :
다음 코드는 파일을 작성하기위한 것입니다
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
//write code to open file
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
//myFile = openFileDialog1.FileName;
System.IO.MemoryStream xmlStream = new System.IO.MemoryStream();
xmlStream.Position = 0;
myDT_For_DGV.ReadXml(openFileDialog1.FileName);
//MessageBox.Show(openFileDialog1.FileName);
}
}
그게 전부 하나 작동하지 않습니다 .. – Yash