public bool TryGetFileInfo(string subpath, out IFileInfo fileInfo) { bool result; try { if (subpath.StartsWith("/", StringComparison.Ordinal)) { subpath = subpath.Substring(1); } string fullPath = this.GetFullPath(subpath); if (fullPath != null) { FileInfo fileInfo2 = new FileInfo(fullPath); if (fileInfo2.Exists && !this.IsRestricted(fileInfo2)) { string compiled = Path.Combine(this.Root, ".Compiled"); LayoutHtmlFile htmlFile = new LayoutHtmlFile(fullPath); fileInfo2 = htmlFile.Compile(compiled); fileInfo = new LayoutPhysicalFileSystem.LayoutPhysicalFileInfo(fileInfo2); result = true; return(result); } } } catch (ArgumentException) { } fileInfo = null; result = false; return(result); }
public bool TryGetDirectoryContents(string subpath, out IEnumerable <IFileInfo> contents) { bool result2; try { if (subpath.StartsWith("/", StringComparison.Ordinal)) { subpath = subpath.Substring(1); } string fullPath = this.GetFullPath(subpath); if (fullPath != null) { DirectoryInfo directoryInfo = new DirectoryInfo(fullPath); bool result; if (!directoryInfo.Exists) { contents = null; result = false; result2 = result; return(result2); } FileSystemInfo[] fileSystemInfos = directoryInfo.GetFileSystemInfos(); IFileInfo[] array = new IFileInfo[fileSystemInfos.Length]; for (int num = 0; num != fileSystemInfos.Length; num++) { FileInfo fileInfo = fileSystemInfos[num] as FileInfo; if (fileInfo != null) { array[num] = new LayoutPhysicalFileSystem.LayoutPhysicalFileInfo(fileInfo); } else { array[num] = new LayoutPhysicalFileSystem.LayoutPhysicalDirectoryInfo((DirectoryInfo)fileSystemInfos[num]); } } contents = array; result = true; result2 = result; return(result2); } } catch (ArgumentException) { } catch (DirectoryNotFoundException) { } catch (IOException) { } contents = null; result2 = false; return(result2); }