C#如何使用不同的不同过程读取和写入xml文件. [英] C# how i can read and write a xml file using different different process.

查看:159
本文介绍了C#如何使用不同的不同过程读取和写入xml文件.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在连续写入xmal文件的同时应用一个应用程序,而其他应用程序正在读取相同的xmal文件.我如何处理此错误,如果在另一个进程中正在使用此文件时出现错误?

I have to application one in continuously writing in xmal file at same time other application is reading this same xmal file . How i can handle this qctually ia m getting a error that this file is in use in another process ?

推荐答案

您需要深入研究内存映射文件:
http://msdn.microsoft.com/en-us/library/dd997372.aspx [ ^ ]

祝你好运!
You need to dive into memory mapped files:
http://msdn.microsoft.com/en-us/library/dd997372.aspx[^]

Good luck!




实际上,您的文件以独占模式打开.在编写器中,完成编写过程后,需要关闭XmlWriter(如果正在使用)对象.如果以只读模式打开xml,则不会看到错误消息.

因此,让我们知道您正在使用哪个类(XmlWriterXmlReaderXDocumentXElement,.... ???)在xml中进行读写.然后我们可能会建议您解决方案.还要发布一些用于读取器和写入器应用程序的代码.

谢谢
-Amit.
Hi,

Actually your file is open with exclusive mode. in your writer you need to close the XmlWriter(if you are using it.) object as and when you are done with the writing process. if you open xml with readonly mode then you will not see the error message.

So, let us know which class(XmlWriter, XmlReader, XDocument, XElement, ....???) you are using for reading and writing in the xml.then we may suggest you the solution. Also post some of the code for reader and writer application.

Thanks
-Amit.


这篇关于C#如何使用不同的不同过程读取和写入xml文件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆