FileStream FileStream=null;
String path="wenjian. XML";
The DataTable DTT=new DataTable ();
XmlSerializer XMLS=new XmlSerializer (typeof (DataTable));
FileStream=new fileStream (path, FileMode. Open, FileAccess. Read, FileShare. Read);
DTT=(DataTable) XMLS. Deserialize (fileStream);
DataGridView2. The DataSource=DTT;
Can compile, but running an exception:
* * * * * * * * * * * * * * exception text * * * * * * * * * * * * * *
System. IO. IOException: file "D: \ \ XML data table serialization \ WindowsFormsApp1 \ WindowsFormsApp1 \ bin \ Debug \ wenjian XML" is being used by another process, so the process cannot access the file,
Code after modification, regenerated solution, compiled into program, VS is not open, do not know why?
CodePudding user response:
FileMode. Open, FileAccess. Read, FileShare ReadWrite