asp.net root paths
- by dejavu
I am getting the exception when trying to save a file:
System.Web.HttpException: The SaveAs method is configured to require a rooted path, and the path '~/Thumbs/TestDoc2//small/ImageExtractStream.bmp' is not rooted.
at System.Web.HttpPostedFile.SaveAs(String filename)
at System.Web.HttpPostedFileWrapper.SaveAs(String filename)
at PitchPortal.Core.Extensions.ThumbExtensions.SaveSmallThumb(Thumb image) in C:\Users\Bich Vu\Documents\Visual Studio 2008\Projects\PitchPortal\PitchPortal.Core\Extensions\ThumbExenstions.cs:line 23
the code is below:
public static void SaveSmallThumb(this Thumb image)
{
var logger = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<ILoggingService>();
string savedFileName = HttpContext.Current.Server.MapPath(Path.Combine(
image.SmallThumbFolderPath,
Path.GetFileName(image.PostedFile.FileName)));
try
{
image.PostedFile.SaveAs(savedFileName);
}
catch (Exception ex)
{
logger.Log(ex.ToString());
}
}
I cant see what is wrong here, any tips?