在做asp.net时,判断上传的图片已经存在?

来源:百度知道 编辑:UC知道 时间:2024/07/03 03:27:24
图片路径是:D:\ASP.NET\Lab_6\Images
string fileName = fullFileName.Substring(fullFileName.LastIndexOf("\\") + 1);//图片名称
string type = fullFileName.Substring(fullFileName.LastIndexOf(".") + 1);//图片格式
请各位大虾们帮忙,解决问题?
尽可能的详细,谢谢!!!
拿文件 002.jpg为例,判断此文件已经存在!!!

取图片名称和扩展名等有自带的方法:
string fileName = Path.GetFileName(fullFileName);
string type = Path.GetExtension(fullFileName);

判断文件是否存在 :
if(File.Exists(fullFileName)){
// 文件已存在
}

注意使用前要引入
using System.IO;

file.Exits(filepath)