C# The process cannot access the file because it is being used by another process
C# The process cannot access the file because it is being used by another process
This error message is mostly comes up,
when you try to access a file which is opened by another process.
You may open an image file in one of your form in a picturebox with usingImageFromFile or something.
I mostly use memorystream to open an image.
After read it in byte[] write it into a stream and close it.
You can check whether a file is being used or not with a simple function.
Try to open a file with none share.
public
bool
IsFileUsedbyAnotherProcess(
string
filename)
{
try
{
File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.None);
}
catch
(System.IO.IOException exp)
{
return
true
;
}
return
false
;
}
This function will return true if
the file because it is being used by another process or not.
C# The process cannot access the file because it is being used by another process的更多相关文章
- FileStream:The process cannot access the file because it is being used by another process
先看下面一段代码(先以共享的方式打开文件读写,然后以只读的方式打开相同文件): FileStream fs = new FileStream(filePath, FileMode.Open, Fil ...
- the process cannot access the file because it is being used by another process
当在IIS中改动绑定的port号后启动时遇到例如以下错误,表明你的port号已经被占用了 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdmljMDIyOA ...
- Go-The process cannot access the file because it is being used by another process.
where? Go程序在读取文件时候 why? 因为有其他进程也在读取和Go程序想要读取的文件,参数冲突 way? 关闭其他程序进程对该文件的读取操作
- Solution: The process cannot access the file [filename] because it is being used by another process.
http://www.brianstevenson.com/blog/solution-the-process-cannot-access-the-file-filename-because-it-i ...
- 自定义容器启动脚本报错:exec user process caused "no such file or directory"
创建容器起不来,一直是restarting状态,查看容器的报错日志如下: standard_init_linux.go:178: exec user process caused "no s ...
- HDFS relaxes a few POSIX requirements to enable streaming access to file system data
https://hadoop.apache.org/docs/r2.7.2/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html Introduction [ ...
- use tomcat to access the file cross the environment
background: 项目中的一个小工具,是一个Cron Job ,每天去搜集下服务器Hadoop Job的运行状态,并生成一份报告发送给整个Team,生产报告的同时把相关的日志文件保存到固定的一台 ...
- Microsoft Office Excel cannot access the file, There are several possible reasons
今天在做EXCEL打印读取模板时报错了,错误信息如下: Microsoft Excel cannot access the file 'D:\xx.xlsx'. There are several p ...
- The process could not read file xxx due to OS error 53
在不同地域的两个SQL Server服务器上配置了复制(Replication)用于同步数据(生产环境配置有Replication,测试环境也配有Replication),两地通过专线连接起来,这 ...
随机推荐
- Flume+LOG4J+Kafka
基于Flume+LOG4J+Kafka的日志采集架构方案 本文将会介绍如何使用 Flume.log4j.Kafka进行规范的日志采集. Flume 基本概念 Flume是一个完善.强大的日志采集工具, ...
- ovirt node的安装简介
Ovirt安装模式 支持install,update,downupdate,reinstall四种安装方式. install:全新安装(以前未安装过ovirt node). update:安装比 ...
- 常用的JQuery数字类型验证正则表达式
var regexEnum = { intege:"^-?[1-9]//d*$", //整数 intege1:"^[1-9]//d*$", ...
- mysql+ssh整合样例,附源代码下载
项目引用jar下载:http://download.csdn.net/detail/adam_zs/7262727 项目源代码下载地址:http://download.csdn.net/detail/ ...
- ios 上拉载入下拉刷新Dome
为练手写了一个小的上拉载入很多其它下拉刷新的小的Dome . 没有太多的技术含量,仅仅是作为新手的启示用.是上一篇下拉载入的扩展.先看一下那个再看这个就easy非常多. Dome下载:http://d ...
- hdu1054(最小顶点覆盖)
传送门:Strategic Game 题意:用尽量少的顶点来覆盖所有的边. 分析:最小顶点覆盖裸题,最小顶点覆盖=最大匹配数(双向图)/2. #include <cstdio> #incl ...
- Django之逆向解析url
Django中提供了一个关于URL的映射的解决方案,你可以做两个方向的使用: 1.有客户端的浏览器发起一个url请求,Django根据URL解析,把url中的参数捕获,调用相应的试图, 获取相应的数据 ...
- 二、第一个ExtJS程序:helloExtJS
开发前的准备 下载并解压ExtJS包后,能够得到下图的文件文件夹结构: 在实际开发过程中并不须要全部的文件和文件夹,所需的包括例如以下文件夹就可以: 若使用eclipse进行开发,仅仅需将上述文件拷贝 ...
- 2014年度辛星解读css第四节
接下来的这一节我计划解说的是超链接和列表的样式,然后我们做出一个导航栏出来,事实上导航栏是很常见的,可是我们这里做得这个有点并不那么完好,等我们学完了css之后再完好它. ************** ...
- 服务器编程入门(3)TCP协议详解
问题聚焦: 本节从如下四个方面讨论TCP协议: TCP头部信息:指定通信的源端端口号.目的端端口号.管理TCP连接,控制两个方向的数据流 TCP状态转移过程:TCP连接的任意一 ...