HttpPostedFile file = context.Request.Files[j];
string fileName = file.FileName;
string fileExtension = System.IO.Path.GetExtension(filepath + file.FileName);
if (!string.IsNullOrEmpty(fileName)
{
string pathToSave_100 = HttpContext.Current.Server.MapPath(filepath) + fileName + fileExtension;
if (File.Exists(pathToSave_100))
{
File.Delete(pathToSave_100);
file.SaveAs(pathToSave_100);
}
else
{
file.SaveAs(pathToSave_100);
}
}
答案 0 :(得分:0)
你可以这样做:
string strFileExtension = Path.GetExtension(file.FileName);