I recently used it in practice.PPCReadXMLThe document encountered a small problem, that isPPCOn the simulator, if you do not go through the following settings, you will not be able to access the local files correctly, always prompt errors, and write your experiences here so that you will not be troubled by this problem.
1,First, we prepareXMLFile, put it in "My documents", and then --> open the simulator --> --〉File--> --〉Configuration--> --〉Shared fold--> Select "My Documents"(You can click here).
After step 1, in the simulator, the shared folder becomes a memory card, that is, the address of this folder isStorage card.
2. Create a smart device project(Here I amWindows Mobile 6)The following interface is designed:
Then, dragOpenfiledialogControl, and double-clickOpenfileButton to enterCodeWrite.
1,The Code is as follows:
Private VoidMenuitem2_click (ObjectSender,EventargsE)
{
Openfiledialog1.showdialog ();
Try
{
StringFile = openfiledialog1.filename. tostring ();//Read XML documents from openfiledialog
StreamreaderSr =New Streamreader(File );
XmltextreaderXTR =New Xmltextreader(SR );
While(XTR. Read ())
{
Listbox1.items. Add ("Nodetype :"+ XTR. nodetype. tostring ());//It can be changed according to the actual situation to verify whether the data is read or not.
}
MessageBox. Show (File );
}
Catch(ExceptionEx)
{
MessageBox. Show (ex. tostring ());
}
}
The running image is as follows:
Open a file
My XML file is test1.xml, which appears after selection
The file path is also displayed."Storage card".
at this point, the local XML file is read.