因为它正由另一个进程使用广东话访问文件因为它、广东话、进程、文件

2023-09-02 02:03:03 作者:明天依然很美

我有我从那里来的网络使用DownloadFile WebClient类的方法,下载文件和做一些修改就可以了一个ASP.NET程序。那么我将其保存到另一个文件夹具有独特name.When我收到此错误

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

该进程无法访问文件D:研发 DOTNET ABC abcimageupload 图像 TempStorage tempImage.jpg',因为它正由另一个进程使用

The process cannot access the file 'D:RDdotnetabcabcimageuploadimagesTempStoragetempImage.jpg' because it is being used by another process

谁能告诉我怎么解决这个问题。

Can anyone tell me how to solve this.

推荐答案

通常情况下,我认为你的code应该找这样的事情。

Generally, I think your code should looking something like this.

WebClient wc = new WebClient();
wc.DownloadFile("https://m.xsw88.com/allimgs/daicuo/20230902/869.png", "Foo.png");
FileStream fooStream;
using (fooStream = new FileStream("foo.png", FileMode.Open))
{
	// do stuff
}
File.Move("foo.png", "foo2.png");