我面临的错误是:
System.Web.HttpException: The SaveAs method is configured to require a rooted path, and the path '~\FileUpload\2019\HS-123.png' is not rooted.
我发现这里的代码有点奇怪:
Dim folderPath1 As String = ("~\FileUpload\" & Today.Year.ToString & "\")
If fileuploadSituation.HasFile Then
Dim extension As String = (Path.GetExtension(fileuploadSituation.FileName))
fileuploadSituation.SaveAs(Server.MapPath(folderPath1) & ID + extension)
End If
此代码在这里工作正常。但不是此代码:
If fileuploadSuggest.HasFile Then
Dim extension1 As String = (Path.GetExtension(fileuploadSuggest.FileName))
fileuploadSuggest.SaveAs(Server.MapPath(folderPath1) & ID + extension1)
End If
它适用于fileuploadSituation,但不适用于fileUploadSuggest,即使它们使用相同的路径。有什么建议可以用来申请吗?