[转]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默认 ...
随机推荐
- spring html特殊字符操作
import org.springframework.web.util.HtmlUtils; /** * html特殊字符操作 * @param answer 操作default=转换为H ...
- 前端MVC学习总结(三)——AngularJS服务、路由、内置API、jQueryLite
一.服务 AngularJS功能最基本的组件之一是服务(Service).服务为你的应用提供基于任务的功能.服务可以被视为重复使用的执行一个或多个相关任务的代码块. AngularJS服务是单例对象, ...
- android 拨打电话小功能
1.其实就是对Intent 的ACTION进行参数设置. 在manifest中药设置打电话的权限: <uses-permission android:name="android.per ...
- ProcessBuilder和Runtime远程执行
http://desert3.iteye.com/blog/1596020 ProcessBuilder.start() 和 Runtime.exec() 方法都被用来创建一个操作系统进程(执行命令行 ...
- [Unity3D]Unity3D游戏开发之在3D场景中选择物体并显示轮廓效果
大家好,我是秦元培,欢迎大家关注我的博客,我的博客地址是blog.csdn.net/qinyuanpei. 在<仙剑奇侠传>.<古剑奇谭>等游戏中,常常须要玩家在一个3D场景中 ...
- Codeforces Round #313 (Div. 1) B. Equivalent Strings DFS暴力
B. Equivalent Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559 ...
- 腾讯微博java(android)sdk新增微博api详细介绍
本文主要介绍腾讯微博android sdk中新增微博有关的8个接口,以及使用的示例代码 注意:以下所有的api示例代码都需要先新建QqTSdkService类对象qqTSdkService并初始化,见 ...
- 【JavaScript】JavaScript Promise 探微
http://www.html-js.com/article/Promise-translation-JavaScript-Promise-devil-details 原文链接:JavaScript ...
- Swift之UIBezierPath
使用UIBezierPath可以创建基于矢量的路径.使用此类可以定义简单的形状,如椭圆.矩形或者有多个直线和曲线段组成的形状等.主要用到的该类的属性包括 moveToPoint: //设置起始点 ad ...
- iOS开发——UI篇Swift篇&玩转UItableView(三)分组功能
UItableView分组功能 class UITableViewControllerGroup: UIViewController, UITableViewDataSource, UITableVi ...