BlogEngine.Core.SyndicationGenerator.ValidateFileName C# (CSharp) Method

ValidateFileName() private static method

Validates the name of the file.
private static ValidateFileName ( IPublishable publishable, string fileName ) : string
publishable IPublishable
fileName string Name of the file.
return string
        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;
        }