当前位置: 首页>>代码示例>>C#>>正文


C# IFileProvider.GetFileInfo方法代码示例

本文整理汇总了C#中IFileProvider.GetFileInfo方法的典型用法代码示例。如果您正苦于以下问题:C# IFileProvider.GetFileInfo方法的具体用法?C# IFileProvider.GetFileInfo怎么用?C# IFileProvider.GetFileInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFileProvider的用法示例。


在下文中一共展示了IFileProvider.GetFileInfo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BaseDocumentHandler

 public BaseDocumentHandler(IFileProvider fileProvider, string subpath)
 {
     FileInfo = AcceptedExtensions
         .Select(x => fileProvider.GetFileInfo(subpath + x))
         .Where(x => x.Exists)
         .FirstOrDefault();
 }
开发者ID:MakingSense,项目名称:aspnet-documentation-middleware,代码行数:7,代码来源:BaseDocumentHandler.cs

示例2: ReadFileContentsSafely

        private static string ReadFileContentsSafely(IFileProvider fileProvider, string filePath)
        {
            var fileInfo = fileProvider.GetFileInfo(filePath);
            if (fileInfo.Exists)
            {
                try
                {
                    using (var reader = new StreamReader(fileInfo.CreateReadStream()))
                    {
                        return reader.ReadToEnd();
                    }
                }
                catch
                {
                    // Ignore any failures
                }
            }

            return null;
        }
开发者ID:alimohammad,项目名称:Orchard2,代码行数:20,代码来源:DefaultRoslynCompilationService.cs

示例3: ResolveFilePath

        internal ResolveFilePathResult ResolveFilePath(IFileProvider fileProvider)
        {
            // Let the file system try to get the file and if it can't,
            // fallback to trying the path directly unless the path starts with '/'.
            // In that case we consider it relative and won't try to resolve it as
            // a full path

            var path = NormalizePath(FileName);

            // Note that we cannot use 'File.Exists' check as the file could be a non-physical
            // file. For example, an embedded resource.
            if (IsPathRooted(path))
            {
                // The path is absolute
                // C:\...\file.ext
                // C:/.../file.ext
                return new ResolveFilePathResult()
                {
                    PhysicalFilePath = path
                };
            }

            var fileInfo = fileProvider.GetFileInfo(path);
            if (fileInfo.Exists)
            {
                // The path is relative and IFileProvider found the file, so return the full
                // path.
                return new ResolveFilePathResult()
                {
                    // Note that physical path could be null in case of non-disk file (ex: embedded resource)
                    PhysicalFilePath = fileInfo.PhysicalPath,
                    FileInfo = fileInfo
                };
            }

            // We are absolutely sure the path is relative, and couldn't find the file
            // on the file system.
            var message = Resources.FormatFileResult_InvalidPath(path);
            throw new FileNotFoundException(message, path);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:40,代码来源:FilePathResult.cs

示例4: SuiteWidgets

 public static IEnumerable<NavigationWidget> SuiteWidgets(IFileProvider fileProvider)
 {
     var file = fileProvider.GetFileInfo("/shared/nav-beta.json");
     var navigationJson = IOFile.ReadAllText(file.PhysicalPath);
     return JsonConvert.DeserializeObject<IEnumerable<NavigationWidget>>(navigationJson);
 }
开发者ID:al-main,项目名称:ui-for-aspnet-mvc-6-demos,代码行数:6,代码来源:NavigationProvider.cs


注:本文中的IFileProvider.GetFileInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。