[转]c# xml.Load() locking file on disk causing errors
本文转自:http://stackoverflow.com/questions/1812598/c-sharp-xml-load-locking-file-on-disk-causing-errors
问:
I have a simple class XmlFileHelper as follows:
publicXmlFileHelper(string xmlFilePath)
{
this.xmlFilePath = xmlFilePath;
xmlDoc.Load(xmlFilePath);
}
this occurs when this class is used to by two running instances
of a component running in parallel both attempting to load the xml file above,
this is legitimate behaviour and required by the application.
答1:
You can do this
using(Stream s =File.OpenRead(xmlFilePath)){
xmlDoc.Load(s);}
instead of
xmlDoc.Load(xmlFilePath);
答2: FileStream xmlFile =newFileStream(xmlFilePath,FileMode.Open,
FileAccess.Read,FileShare.Read);
xmlDoc.Load(xmlFile);
[转]c# xml.Load() locking file on disk causing errors的更多相关文章
- cannot load such file -- openssl
[test@localhost usr]$ /usr/local/ruby/bin/gem install bundler ERROR: Loading command: install (LoadE ...
- Python load json file with UTF-8 BOM header - Stack Overflow
Python load json file with UTF-8 BOM header - Stack Overflow 3 down vote Since json.load(stream) use ...
- require './ex25' can't load such file
require './ex25' can't load such file 在练习learn ruby the hard way时候,第25题,发生了一下错误 LoadError: cannot lo ...
- Oracle EBS数据定义移植工具:Xdf(XML Object Description File)
转载自:http://www.orapub.cn/posts/3296.html Oracle EBS二次开发中,往往会创建很多数据库对象,如表.同义词.视图等,这些数据库对象是二次开发配置管理内容很 ...
- bundle install 安装的 gem 提示 cannot load such file
/usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load ...
- redis-trib.rb报错:/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- redis (LoadError)
报错如下: /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- redis ...
- 2017.12.20 Java中的 IO/XML学习总结 File类详细
IO / XML 一.File类 1.定义/概念 Java是面向对象的语言,要想把数据存到文件中,就必须要有一个对象表示这个文件.File类的作用就是代表一个特定的文件或目录,并提供了若干方法对这些文 ...
- fedora安装rails缺少js runtime和cannot load such file -- sqlite3/sqlite3_native解决办法
装完rails后创建应用程序: rails new demo 进入创建的demo文件夹 cd demo 检查安装环境 rake about 这时出现错误 Could not find a JavaSc ...
- Unable to load template file 'rj\ThinkPHP/Tpl/dispatch_jump.tpl'----thinkphp3.2.3
Unable to load template file 'rj\ThinkPHP/Tpl/dispatch_jump.tpl'----thinkphp3.2.3 1.报错原因:将thinkphp默认 ...
随机推荐
- C#方法封装与重构
C#作为一个完全面向对象的语言,有个特性很重要但是往往会不重视,而不重视的结果就会造成代码杂乱难以解读.维护.这个特性就是封装. 这里不是大谈C#的封装,我只讲一个,关于方法封装的一些问题. ...
- 基于KVM的虚拟化研究及应用
引言 虚拟化技术是IBM在20世纪70年代首先应用在IBM/370大型机上,这项技术极大地提高了大型机资源利用率.随着软硬件技术的迅速发展,这项属于大型机及专利的技术开始在普通X86计算机上应用并成为 ...
- jqGrid初次使用遇到的问题及解决方法
问题一:初始化定义翻页用的导航栏时,表中出现"undefined"方框: 解决:需要导入grid.locale-cn.js文件. 问题二:页面只有一页,无法翻页: 解决:初始化设置 ...
- 拖动窗体FormBorderStyle属性为None的窗体移动
winform窗体的样式很单一,不够漂亮,往往我们需要对窗体进行重写,但是我们又要保留在重写前窗体本身带的功能,例如拖动窗体的头进行移动之类的. 一下方式可以实现该方法: [DllImport(&qu ...
- 【HTML】Jquery前台传参及接收
在一些网页应用中,有的时候需要前台之间传递参数,通过JS语法来做一些判断处理. 发送端:(a页面) <a href="b.html?Show=true" id="t ...
- BZOJ 1045: [HAOI2008] 糖果传递 数学
1045: [HAOI2008] 糖果传递 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=1045 Description 有n个小朋友坐 ...
- Codeforces Round #338 (Div. 2) C. Running Track dp
C. Running Track 题目连接: http://www.codeforces.com/contest/615/problem/C Description A boy named Ayrat ...
- INDY idhttp Post用法
http://www.cnblogs.com/tk-del/archive/2013/05/10/3071541.html function Post(AURL: string; ASource: T ...
- 【Hybrid App】Hybrid App开发实战
[引言]近年来随着移动设备类型的变多,操作系统的变多,用户需求的增加,对于每个项目启动前,大家都会考虑到的成本,团队成员, 技术成熟度,时间,项目需求等一堆的因素.因此,开发App的方案已经变得越来越 ...
- 一步步学习PHP笔记(李炎恢瓢城web俱乐部-多用户留言系统)01
本课:div+css实现首页效果: 开发工具:xampp + phpstorm 笔记目的:仅做记录使用,方便日后查看 代码目录结构: index.php: <?php define(" ...