server.mappath issue
I have this variable that holds a path.
I want to see the result for MapPath using this variable, but I get this error. Any Idea?
string FolderName = "Docs/1/1232"
'Server.MapPath(FolderName)' threw an exception of type 'System.Web.HttpException'
Stack trace:
at System.Web.Configuration.UserMapPath.GetPhysicalPathForPath(String path, VirtualDirectoryMapping mapping) at System.Web.Configuration.UserMapPath.GetPathConfigFilename(String siteID, VirtualPath path, String& directory, String& baseName) at System.Web.Configuration.UserMapPath.MapPath(String siteID, String path) at System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull) at System.Web.Hosting.HostingEnvironment.MapPathInternal(VirtualPath virtualPath) at System.Web.VirtualPath.MapPathInternal() at System.W开发者_开发问答eb.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping) at System.Web.HttpRequest.MapPath(VirtualPath virtualPath) at System.Web.HttpServerUtility.MapPath(String path) at FileUpload.CreateFolder(String FolderName) in c:\Projects\WebSites\MyShul\FileUpload.aspx.cs:line 186 at FileUpload.UploadFile() in c:\Projects\WebSites\MyShul\FileUpload.aspx.cs:line 53 at FileUpload.btnUpload_Click(Object sender, EventArgs e) in c:\Projects\WebSites\MyShul\FileUpload.aspx.cs:line 236 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
The path you are trying to map does not exist in the virtual directory.
Make sure you are using a correct path (for your example, probably the space is wrong).
精彩评论