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),两地通过专线连接起来,这 ...
随机推荐
- 使用CocoaPods出现 The `master` repo requires CocoaPods 0.32.1 - 问题解决
近期在使用CocoaPods为project配置第三方类库时出现了例如以下问题: [!] The `master` repo requires CocoaPods 0.32.1 - 明显是由于Coco ...
- 第四题(迅雷笔试题):编写一个程序,开启3个线程,这3个线程的ID分别为A、B、C,每个线程将自己的ID在屏幕上打印10遍,要求输出结果必须按ABC的顺序显示;如:ABCABC….依次递推。
#include <iostream> #include <stdlib.h> #include <pthread.h> using namespace std; ...
- Android 实现自己定义多级树控件和全选与反选的效果
博文開始之前,首先要感谢大牛:(lmj623565791),本博文是在其博文http://blog.csdn.net/lmj623565791/article/details/40212367基础上进 ...
- nginx源代码分析--高性能server开发 常见的流程模型
1.高性能server 对于高性能server对于.处理速度和占用空间小是典型特性.特别是当server经验C10K问题的时候(网络server在处理数以万计的client连接时.往往出现效率低下甚至 ...
- WebService的相关使用
近期公司项目使用WebService ,这里简单做个总结. 事实上详细使用细节有些情况下须要改,还须要看实际情况,须要与server联调,详细沟通. 比方公司连接,非要把envelope.dotNet ...
- kobox : key_wq.c -v1 如何使用工作队列 workqueue
kobox: key_wq.c - v1 说明: TQ2440主要驱动因素,四个按键驱动的处理 key_wq.c和key.c类别似,与key.c之间的差异的主要驱动力: key.c使用计时器,在中断发 ...
- 使用xml和java代码混合控制UI界面
main.xml.................... <?xml version="1.0" encoding="utf-8"?> <Li ...
- stripslashes和addslashes的区别
我们在向mysql写入数据时,比如: mysql_query(”update table set `title`=’kuhanzhu’s blog’”); 那就会出错.同asp时一样,数据库都会对单引 ...
- selenium webdriver缺陷
关闭 selenium webdriver缺陷 除了http://573301735.com/?p=5126讲 的,昨天又发现一个让我1个小时生不如死的问题,就是使用两个不同的配置文件来初始化dri ...
- centos5.5字体为方块问题的解决_深入学习编程_百度空间
centos5.5字体为方块问题的解决_深入学习编程_百度空间 centos5.5字体为方块问题的解决 一.yum -y install fonts-chinese二.yum -y install f ...