从文件夹中删除图像 [英] delete the image from folder

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

问题描述

我正在使用gridview,在gridview中我有一个复选框列,我使用删除按钮删除Checked记录。我正在通过asp.net fileUpload Server Control上传图片。在数据库中我只是存储图像名称及其扩展名为ex Image1.jpg和我在应用程序根路径中存储在Images文件夹中的相同名称。

现在问题是当我删除任何记录那么那些图像也应该从根路径中的Images文件夹中删除怎么做..?。



如何从d''找到特定的id和那个文件名图像文件夹中带有图像名称的基础和数学。

任何人都可以给我一个解决方案......?

i am using gridview and in gridview i have a checkbox column and i using delete button to delete the Checked record. i am uploading images through asp.net fileUpload Server Control. and in a DataBase i am just Storing the Image Name with its Extension for ex Image1.jpg and same name i am storing in Images folder in my Application root path.
now problem is when i delete any record then that images should also delete from the Images folder from root path how to do that..?.

how to find perticular id and that file name from d''base and math with image name in Image Folder.
can any one give me a solution...?

推荐答案

我本可以找到该文件并使用 File.Delete方法 [ ^ ]从目录中删除文件。

试试这个:

I could have located the file and used File.Delete Method[^] to delete the file from directory.
Try this:
System.IO.File.Delete("MyFilePath");





--Amit



--Amit


尝试下面给出的代码:



Try the code given below:

string completePath = Server.MapPath("YourFilePath");

if (System.IO.File.Exists(completePath))
{

System.IO.File.Delete(completePath);

}


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

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