Error environment:
Write some content in the XML document. The entire process is:
First, check whether the XML file is in the current path. If so, use xmldocument. Load () to load the file. If not, create the XML file and save it with xmldocument. Save (string ).
ErrorCodeAs follows:
// XML file name m_xmlfilename = "filerecvrecord. XML "; // get the file name (including the full path name) string filefullname = directory. getcurrentdirectory () + @ "\" + m_xmlfilename; // check whether the file contains m_isfileexisted = file. exists (filefullname );
Save the XML file code:
M_xmldoc.save (m_xmlfilename );
Error:
The newly created XML file should be in the current directory, but cannot be found
Error cause:
After finding the file, you will find that the newly created XML file is under "My Documents" instead of the current directory.
Later, I thought it might be becauseAn error occurred while using xmldocument. Save ().
After modifying the code, we found that this was the case.
Public:Virtual Void Save(String ^Filename)
Parameters Filename Indicates Location of the file to be saved
Because my m_xmlfilename only saves the file name, but does not include the path name, this problem occurs.
Solution error:
Xmldocument. Save (string filename), saved in ParametersFile Name (must contain absolute path)
The modified code is as follows:
// XML file name (including full path name) m_xmlfilename = directory. getcurrentdirectory () + @ "\ filerecvrecord. xml"; // check whether the file exists m_isfileexisted = file. exists (m_xmlfilename );