本文介绍了读取/写入XML文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,该应用程序列出了xml文件中的数据,并且用户可以在此xml文件中添加更多条目.稍后,当再次填充此列表时,将显示较新的条目以及较旧的条目.
我的xml文件位于我当前的项目文件夹&中.它的"BUILD ACTION"设置为"CONTENT"
& 复制到输出目录"是总是复制".
现在,当我运行项目时,此xml文件将复制到"Debug"文件夹中.然后修改并更新Output目录中的此文件,并正确显示所有值.
现在的问题是,当我重新启动项目时,再次将此文件复制到Debug文件夹&中.所有更新都将丢失....
请建议我可以使用相同文件并对其进行修改的方式,以使所做的任何更改都不会丢失...
另外,如果我将文件名指定为(@"C:\ file.xml"),则会显示对象引用未设置为对象的实例"错误.
在此先感谢....

I am developing an application which list the data from an xml file, and user can add more entries into this xml file. Later, when this list is again populated, newer entries will be displayed back along with older ones.
My xml file is in my current project folder, & its "BUILD ACTION" is set as "CONTENT"
& "COPY TO OUTPUT DIRECTORY" is "COPY ALWAYS".
Now, when i run the project, this xml file gets copied into "Debug" folder. And then this file in Output directory gets modified and updated and all values are displayed fine.
Now the problem s that, when i restart the project, again this file is copied to Debug folder & all updates are lost....
Kindly suggest ways in which i can use the same file and modify it, so that no change made is lost...
Also, if i specify the name of file as (@"C:\file.xml"), the it show "Object reference not set to an instance of an object" error.
Thanks in advance....

推荐答案


这篇关于读取/写入XML文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 08:50
查看更多