如何删除服务器上的图像 [英] How do i delete a image on my server

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

问题描述

Heey all



i我正在为网店创建一个系统



我遇到了一个小问题



i我正在使用详情查看我的产品



现在我需要删除一个产品,问题是如何删除我服务器上文件夹中的图像??



我的数据库看起来像:



产品ID

产品名称

ProductDesc

ProductPrice

ProductImage



ProductImage具有FilePath和ImageName到图像

Heey all

i am creating a system for for a webshop

and i have run into a little problem

i am using a detailsview to see my products

and now i need to delete a Product, the question is how do i delete the Image that are in a folder on my server??

my database look like:

ProductID
ProductName
ProductDesc
ProductPrice
ProductImage

"ProductImage" has the FilePath and ImageName to the image

推荐答案

string path = "E:\\sasi\\delt.doc";
        FileInfo myfileinf = new FileInfo(path);
        myfileinf.Delete();







确保ASP用户拥有此权限夹。默认情况下,此用户无法访问大部分硬盘..




Make sure the ASP user has permissions to this folder. By default this user is not given access to much of the harddrive..


Use NameSpace: using System.IO;







File.Delete(Server.MapPath("~/ProductImage/" + ProductImage));





请记住:产品图片的格式应为:image.jpg ......



Remember: Product Image should be in format : image.jpg......


if (System.IO.File.Exists(@"C:\test.txt"))
    System.IO.File.Delete(@"C:\test.txt"));





试试这个



Try this


这篇关于如何删除服务器上的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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