Question

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.

Was it helpful?

Solution

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))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top