如果文件名不同,如何删除旧文件并添加新文件 [英] how to delete the old file and add new file if the filename is different
本文介绍了如果文件名不同,如何删除旧文件并添加新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void btnsubmit_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
if (checkfiletype(FileUpload1.PostedFile.FileName))
{
string filepath = "~/VolunteerResumes/" + page2.ID + "_" + FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath(filepath));
}
}
}
推荐答案
Dim Image_Location As String = ""
ranNumber = rndNumber.Next()
strPath = "~\ChartImages" & "\User_" & System.Web.HttpContext.Current.Session("UserId") & "\Report_" & ChartTableID & "\"
.ImageType = ChartImageType.Jpeg
If Not IsNothing(System.Web.HttpContext.Current.Session) Then
If Not IsNothing(System.Web.HttpContext.Current.Session("UserId")) Then
Image_Location = HttpContext.Current.Server.MapPath(strPath)
End If
.ImageStorageMode = ImageStorageMode.UseImageUrl
If Image_Location <> "" Then
Dim _dir As New DirectoryInfo(Image_Location)
If Not _dir.Exists Then
_dir.Create()
End If
.ImageUrl = strPath & ranNumber
End If
End If
这篇关于如果文件名不同,如何删除旧文件并添加新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文