无法访问文件,因为它被另一个进程使用 [英] Cant Access File because it is being used by another process
本文介绍了无法访问文件,因为它被另一个进程使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
进程无法访问文件D: \RDE\\\\\\\\\\\\\\\\\\\\\\,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, $ b
任何人都可以告诉我如何解决这个问题。
解决方案一般来说,我认为你的代码应该是这样的。
WebClient wc = new WebClient();
wc.DownloadFile(http://stackoverflow.com/Content/Img/stackoverflow-logo-250.png,Foo.png);
FileStream fooStream;
using(fooStream = new FileStream(foo.png,FileMode.Open))
{
// do stuff
}
File.Move(foo .png,foo2.png);
I have an ASP.NET program where i am downloading a file from web using DownloadFile method of webClient Class and the do some modifications on it. then i am Saving it to another folder with a unique name.When I am getting this error
The process cannot access the file 'D:\RD\dotnet\abc\abcimageupload\images\TempStorage\tempImage.jpg' because it is being used by another process
Can anyone tell me how to solve this.
解决方案Generally, I think your code should looking something like this.
WebClient wc = new WebClient(); wc.DownloadFile("http://stackoverflow.com/Content/Img/stackoverflow-logo-250.png", "Foo.png"); FileStream fooStream; using (fooStream = new FileStream("foo.png", FileMode.Open)) { // do stuff } File.Move("foo.png", "foo2.png");
这篇关于无法访问文件,因为它被另一个进程使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文