IOException: The process cannot access the file 'file path' because it is being used by another process

前端 未结 10 2051
陌清茗
陌清茗 2020-11-22 00:13

I have some code and when it executes, it throws a IOException, saying that

The process cannot access the file \'filename\' because it

10条回答
  •  一生所求
    2020-11-22 00:35

    Had an issue while uploading an image and couldn't delete it and found a solution. gl hf

    //C# .NET
    var image = Image.FromFile(filePath);
    
    image.Dispose(); // this removes all resources
    
    //later...
    
    File.Delete(filePath); //now works
    

提交回复
热议问题