图像不能从文件夹中删除 [英] Image not delete from folder

查看:114
本文介绍了图像不能从文件夹中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从文件夹中删除图像时错误信息是

(因为它正由另一个进程使用)。



我尝试过的事情:



When i delete image from folder "Error Message is
(Because it is being used by another process).

What I have tried:

Dim Get_Image_From_Product_Image As New SqlCommand("SELECT Business_Image FROM ImageDB.dbo.Administrator_Account Where Employee_Code = '" & CmbUserCode & "'", sqlcon)

            Dim Get_Image_FromProduct_Image = Get_Image_From_Product_Image.ExecuteScalar().ToString()

 PicturePath = Application.StartupPath & "\Product_Image"

  System.IO.File.Delete(PicturePath & "\" & Get_Image_FromProduct_Image)

推荐答案

正如CHill60所说,错误信息非常清楚 - 您正在尝试写入的文件正在使用中。几乎可以肯定,它由您自己的软件使用 - 所以首先检查您读取或写入该文件的所有位置。除非您关闭(并且最好是Dispose)您完成它们时使用的所有流,否则它们将保持打开状态,并且您的应用程序无法再次使用该文件。

如果您从中加载图像,则同样适用文件:源文件保持锁定状态,直到图像处理完毕或您的应用程序关闭为止,以先到者为准。
As CHill60 says, the error message is pretty clear - the file you are trying to write to is in use. Almost certainly, it's in use by your own software - so start by checking everywhere you read or write that file. Unless you Close (and preferably Dispose) all the stream you use when you are finished with them, they remain open and you app cannot use that file again.
The same thing applies if you load an Image from the file: the source file remains locked until the Image has been Disposed or your app closes, whichever comes first.


这篇关于图像不能从文件夹中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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