Using: Visual Studio
Language: Visual Basic
I already loaded a xml file to my datagrid already, what i am trying to do is have the option to save the datagrid data back as an xml file. I have the code, but how do I close the original xml file that is in use in the datagrid so that it will let me save the file back to the file?
'define a save dialog Dim save_file As New SaveFileDialog 'give its extension save_file.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*" 'select xml save_file.FilterIndex = 2 'create a datatable Dim my_datatable As New DataTable 'if ok click If save_file.ShowDialog() = DialogResult.OK Then 'get datagridview source to datatable my_datatable = CType(DataGridView1.DataSource, DataTable) 'save datatable with xml format my_datatable.WriteXml(save_file.FileName) End If
When i try to save it to the same file i loaded it to the datagrid, error says file already in use, cannot save. How do i bypass that or update the grid and at the same time update the file?
Edited 2 Years Ago by VUEKID