protected VirtualFileInfo GetFileInfoInternal(string virtualFilePath, bool mustExist, out string absolutePath) { try { if (String.IsNullOrEmpty(virtualFilePath)) { VfsLog.Debug("File request without file path received."); throw new ResourceAccessException("An empty or null string is not a valid file path"); } //make sure we operate on absolute paths absolutePath = PathUtil.GetAbsolutePath(virtualFilePath, RootDirectory); if (IsRootPath(absolutePath)) { VfsLog.Debug("Blocked file request with path '{0}' (resolves to root directory).", virtualFilePath); throw new ResourceAccessException("Invalid path submitted: " + virtualFilePath); } var fi = new FileInfo(absolutePath); VirtualFileInfo fileInfo = fi.CreateFileResourceInfo(); //convert to relative paths if required (also prevents qualified paths in validation exceptions) if (UseRelativePaths) { fileInfo.MakePathsRelativeTo(RootDirectory); } //make sure the user is allowed to access the resource ValidateResourceAccess(fileInfo); //verify file exists on FS if (mustExist) { fileInfo.VerifyFileExists(RootDirectory); } return(fileInfo); } catch (VfsException) { //just bubble internal exceptions throw; } catch (Exception e) { VfsLog.Debug(e, "Could not create file based on path '{0}' with root '{1}'", virtualFilePath, RootDirectory); throw new ResourceAccessException("Invalid path submitted: " + virtualFilePath); } }