我们可以同时编写和读取xml文件吗? [英] can we write and read a xml file simultaniously?

查看:98
本文介绍了我们可以同时编写和读取xml文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从xml文件读取数据,也要写入xml文件.该间隔为一分钟.

解决方案

您不能(也不应)同时做这两项. XML文件是顺序的文本文件,因此尝试同时写入和读取会给您的应用程序带来问题.


如上所述,这可能会给您的应用程序带来问题,因此请避免使用它寻找其他选择.
这是你的问题的答案

 FileStream objFs = 新建 FileStream(文件名,FileMode.Open,FileAccess.ReadWrite,FileShare.Read); 


I want to read the data from the xml file and also write to xml file. the interval will be one minute.

解决方案

You cannot (and should not) do both at the same time. XML files are sequential text files, so trying to write and read at the same time would cause problems for your application.


As suggested above this could cause problem to your application so try to avoid it look for some another option.
And this is answer for you question

FileStream objFs = new FileStream(Filename, FileMode.Open, FileAccess.ReadWrite, FileShare.Read);


这篇关于我们可以同时编写和读取xml文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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