如何从文件夹中删除图像 [英] how to delete the image from an folder

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

问题描述

请参阅我未使用静态路径.
我想删除具有相对路径的文件.
例如
〜/student_image/student_photo/j.jpg"

see i am not using the static path.
i want to delete the file which has relative path.
for example
"~/student_image/student_photo/j.jpg"

got it or you need more specification.

推荐答案

您可以使用Page.MapPath获取物理路径.

尼克
You can get the physical path with Page.MapPath.

Nick


以下代码将帮助您.....

Following code will help you .....

try {
FileInfo myFile= new FileInfo(MapPath(".") + "\\" + yourfilename);
if (myFile.Exists) {
File.Delete(MapPath(".") + "\\" + yourfilename);
}
else {
throw new FileNotFoundException();
}


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

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