private static string ValidateFileName(IPublishable publishable, string fileName)
{
fileName = fileName.Replace(publishable.Blog.AbsoluteWebRoot.ToString(), string.Empty);
try
{
var physicalPath = HttpContext.Current.Server.MapPath(fileName);
var info = new FileInfo(physicalPath);
fileSize = info.Length;
fileExists = true;
}
catch (Exception)
{
// if file does not exist - try to strip down leading
// directory in the path; sometimes it duplicated
if (fileName.IndexOf("/") > 0)
{
fileName = fileName.Substring(fileName.IndexOf("/") + 1);
ValidateFileName(publishable, fileName);
}
}
return publishable.Blog.AbsoluteWebRoot + fileName;
}