문제

I have created an intranet application and am having some difficulties with IE and safari on windows when trying to use the following code to save a posted file to an internal folder within the MVC solution folder structure:

postedFile.SaveAs(HttpContext.Current.Server.MapPath("~/" + baseFolderName + "/" + contentFolder + "/" + fileName));

This works as expected when using Firefox and chrome so I am unsure as to why this is happening something to do with the format of the string.

System.NotSupportedException: The given path's format is not supported.

The name of the basefolder and contentfolder being passed are the same in the tests so I am assuming the problem lies with IE trying to find the path.

도움이 되었습니까?

해결책

IE was getting the FileName of the posted file with its location included. I resolved the issue by getting just the file extension with the following code:

System.IO.Path.GetFileName(image.FileName))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top