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


C# IFileSystem.GetFileInfo方法代码示例

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


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

示例1: EnsureList

        /// <summary>
        /// Ensures the list.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="file">The file.</param>
        /// <param name="httpClient">The HTTP client.</param>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="semaphore">The semaphore.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task.</returns>
        public static async Task EnsureList(string url, string file, IHttpClient httpClient, IFileSystem fileSystem, SemaphoreSlim semaphore, CancellationToken cancellationToken)
        {
            var fileInfo = fileSystem.GetFileInfo(file);

            if (!fileInfo.Exists || (DateTime.UtcNow - fileSystem.GetLastWriteTimeUtc(fileInfo)).TotalDays > 1)
            {
                await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false);

                try
                {
                    var temp = await httpClient.GetTempFile(new HttpRequestOptions
                    {
                        CancellationToken = cancellationToken,
                        Progress = new Progress<double>(),
                        Url = url

                    }).ConfigureAwait(false);

					fileSystem.CreateDirectory(Path.GetDirectoryName(file));

					fileSystem.CopyFile(temp, file, true);
                }
                finally
                {
                    semaphore.Release();
                }
            }
        }
开发者ID:paul-777,项目名称:Emby,代码行数:38,代码来源:ImageUtils.cs

示例2: LocalFileStream

        public LocalFileStream(IFileSystem fileSystem, string relativePath, string contentType)
            : base(contentType)
        {
            Contract.Requires(fileSystem != null);

            RelativePath = relativePath;
            _fileInfo = fileSystem.GetFileInfo(relativePath);
            _stream = new Lazy<Stream>(() => fileSystem.Open(relativePath, FileMode.Open));
        }
开发者ID:jchadwick,项目名称:ClientResourceManager,代码行数:9,代码来源:LocalFileStream.cs

示例3: FromFile

        public static Project FromFile(string input, IFileSystem fileSystem)
        {
            var jObject = JsonConvert.DeserializeObject<Dictionary<string, JToken>>(input);
            var project = new Project();

            foreach (var entry in jObject)
            {
                var kindObj = entry.Key;
                string[] list;
                if (entry.Value is JArray)
                    list = entry.Value.ToObject<string[]>();
                else
                    list = new[] {entry.Value.ToObject<string>()};

                foreach (var item in list)
                {
                    var info = fileSystem.GetFileInfo(PathInfo.Create(item));
                    if (info == null)
                    {
                        var globPattern = GlobPattern.Create(item);
                        if (!globPattern.IsWildcard)
                            throw new InvalidProjectFileException($"Could not find file {item}.");

                        var items = fileSystem.GetFiles(globPattern);
                        foreach (var file in items)
                        {
                            var fileItem = new FileProjectItem(kindObj, file, fileSystem);
                            ProjectItem existing;
                            if (!project.TryGetItemById(fileItem.Identifier, out existing))
                                project.AddItem(fileItem);
                        }

                        project.AddSubscription(fileSystem.Subscribe(globPattern, a =>
                        {
                            HandleChange(a, project, kindObj, fileSystem);
                        }));
                    }
                    else
                    {
                        AddFile(fileSystem, project, kindObj, info, item);
                    }
                }
            }

            return project;
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:46,代码来源:Project.cs


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