一个非托管的FileNotFoundException的问题
WINDOWS MOBILE平台中我的程序中用XmlDocument对象来操作XML文档,程序的流程和代码都没有问题,但是点击按钮触发事件时弹出了一个非托管的FileNotFoundException
是不是 XmlDocument对象.Load("xxx.xml"); 有问题?xxx.xml是部署在同一个目录下的,应该找得到啊?
请了解的同志帮忙看一下是什么问题,跪谢!!!
---------毕设的问题,眼看就要交东西了,急啊!!
代码如下:
XmlDocument XMLDoc = new XmlDocument();
XMLDoc.Load("xxx.xml");
XmlElement newCash=XMLDoc.CreateElement("cashItem");//创建一个新的<cashItem>结点
newCash.SetAttribute("cashIndex","date");
XmlNode root=XMLDoc.FirstChild; //获取根结点financial结点
XmlNode subRoot=root.FirstChild;
XmlNode cash=subRoot.NextSibling; //找到<cash>结点,这里先没考虑空结点
//给新的<cashItem>结点填上内容,将4个子元素添加到<cashItem>结点下
XmlElement newCash1=XMLDoc.CreateElement("cashNum");
newCash1.InnerText=this.txt2.Text.ToString();
newCash.AppendChild(newCash1);
XmlElement newCash2=XMLDoc.CreateElement("cashType");
if(this.radioButton1.Checked)
newCash2.InnerText=this.radioButton1.Text.ToString();
else if(this.radioButton2.Checked)
newCash2.InnerText=this.radioButton2.Text.ToString();
newCash.AppendChild(newCash2);
XmlElement newCash3=XMLDoc.CreateElement("cashDate");
newCash3.InnerText=date;
newCash.AppendChild(newCash3);
XmlElement newCash4=XMLDoc.CreateElement("cashPs");
newCash4.InnerText=this.textBox1.Text.ToString();
newCash.AppendChild(newCash4);
cash.AppendChild(newCash); //将新的<cashItem>结点添加到<cash>下
XMLDoc.Save("xxx.xml");
XML文档:
<?xml version="1.0" encoding="gb2312" ?>
<Financial>
<sumup>
<estate>100</estate>
<ondebt>100</ondebt>
<net>0</net>
</sumup>
<cash cashSum="100">
<cashItem cashIndex="2008-5-1">
<cashNum>50</cashNum>
<cashType>支出</cashType>
<cashDate>2008-5-1</cashDate>
<cashPs>欢乐空间KTV,2小时</cashPs>
</cashItem>
</cash>
<deposit depositSum="100">
<depositItem depositIndex="工商银行">
<depositNum>50</depositNum>
<depositType>取款</depositType>
<depositDate>2008-5-1</depositDate>
</depositItem>
</deposit>
</Financial>