该进程无法访问该文件,因为该文件正在被另一个文件使用 [英] The process cannot access the file because it is being used by another

查看:122
本文介绍了该进程无法访问该文件,因为该文件正在被另一个文件使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

论坛未答复的红利问题条款FAQsSearchContest我的帐户注销该进程无法访问该文件,因为该文件正在被另一个人使用.由开发人员于12年5月28日上午02:14大家好,

我已使用以下代码删除ASP.net 4.0中的临时文件(.PDF).

ForumUnansweredBonus QuestionsArticlesFAQsSearchContestMy AccountSign-out The process cannot access the file because it is being used by anotherAsked By dev rathore on 28-May-12 02:14 AMHi All,

I have used below code to delete temp file(.PDF) in ASP.net 4.0.

if(File.Exists(FilePath))
{
try
{
File.Delete(FilePath);
}




但在错误以下得到提示:




but gettting below error:

The process cannot access the file 'D:\devendra\web\TempWorkAreaPdf\AdmitCard_C58YE26SB7.pdf' because it is being used by another process.


请帮助我,以便我可以删除临时文件.


Please help me so that i can delete the tempfile.

推荐答案

可能是您的代码正在使用该文件:检查在哪里创建和使用临时文件,并确保完成后已正确关闭并释放了所有文件流和相关对象.只是让它们超出范围并不能做到这一点-它等待垃圾收集器执行,这可能要花费数周的时间!
The chances are it is your code that is using the file: check where you create and use the temporary file, and ensure that you have correctly Closed and Disposed all file streams and related objects when you have finished with it. Just letting them go out of scope does not do this - it waits for the Garbage collector to do it which may not be for weeks!


这篇关于该进程无法访问该文件,因为该文件正在被另一个文件使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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