• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Abstractions.FileInfoBase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.IO.Abstractions.FileInfoBase的典型用法代码示例。如果您正苦于以下问题:C# FileInfoBase类的具体用法?C# FileInfoBase怎么用?C# FileInfoBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FileInfoBase类属于System.IO.Abstractions命名空间,在下文中一共展示了FileInfoBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Load

        public SingleTestRunBase Load(FileInfoBase fileInfo)
        {
            var document = this.ReadResultsFile(fileInfo);
            var features = this.ToFeatures(document);

            return new SpecRunSingleResults(features);
        }
开发者ID:picklesdoc,项目名称:pickles,代码行数:7,代码来源:SpecRunSingleResultLoader.cs


示例2: ReadResultsFile

        private XDocument ReadResultsFile(FileInfoBase testResultsFile)
        {
            XDocument document;
            using (var stream = testResultsFile.OpenRead())
            {
                using (var streamReader = new System.IO.StreamReader(stream))
                {
                    string content = streamReader.ReadToEnd();

                    int begin = content.IndexOf("<!-- Pickles Begin", StringComparison.Ordinal);

                    content = content.Substring(begin);

                    content = content.Replace("<!-- Pickles Begin", string.Empty);

                    int end = content.IndexOf("Pickles End -->", System.StringComparison.Ordinal);

                    content = content.Substring(0, end);

                    content = content.Replace("&lt;", "<").Replace("&gt;", ">");

                    var xmlReader = XmlReader.Create(new System.IO.StringReader(content));
                    document = XDocument.Load(xmlReader);
                }
            }

            return document;
        }
开发者ID:picklesdoc,项目名称:pickles,代码行数:28,代码来源:SpecRunSingleResultLoader.cs


示例3: SpecRunSingleResults

        public SpecRunSingleResults(FileInfoBase fileInfo)
        {
            var resultsDocument = this.ReadResultsFile(fileInfo);

            this.specRunFeatures =
                resultsDocument.Descendants("feature").Select(Parser.SpecRun.Factory.ToSpecRunFeature).ToList();
        }
开发者ID:MikeThomas64,项目名称:pickles,代码行数:7,代码来源:SpecRunSingleResults.cs


示例4: MakeRelativePath

        public static string MakeRelativePath(DirectoryInfoBase fromPath, FileInfoBase toPath)
        {
            if (fromPath == null) throw new ArgumentNullException("fromPath");
            if (toPath == null) throw new ArgumentNullException("toPath");

            string root = fromPath.FullName;
            if (!(root.EndsWith("\\") || root.EndsWith("/")))
                root += "\\";
            root += "a.txt";

            Uri fromUri = new Uri(root);
            Uri toUri = new Uri(toPath.FullName);

            if (fromUri.Scheme != toUri.Scheme) { return toPath.FullName; } // path can't be made relative.

            Uri relativeUri = fromUri.MakeRelativeUri(toUri);
            string relativePath = Uri.UnescapeDataString(relativeUri.ToString());

            if (toUri.Scheme.ToUpperInvariant() == "FILE")
            {
                relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
            }

            return relativePath;
        }
开发者ID:orloffm,项目名称:OrlovMikhail.Tools,代码行数:25,代码来源:IOTools.cs


示例5: Load

        public XDocument Load(FileInfoBase fileInfo)
        {
            XDocument document;
            using (var stream = fileInfo.OpenRead())
            {
                document = this.Load(stream);
            }

            return document;
        }
开发者ID:picklesdoc,项目名称:pickles,代码行数:10,代码来源:XDocumentLoader.cs


示例6: AddFile

 public static void AddFile(this ZipArchive zipArchive, FileInfoBase file, string directoryNameInArchive)
 {
     string fileName = Path.Combine(directoryNameInArchive, file.Name);
     ZipArchiveEntry entry = zipArchive.CreateEntry(fileName, CompressionLevel.Fastest);
     using (Stream zipStream = entry.Open(),
                   fileStream = file.OpenRead())
     {
         fileStream.CopyTo(zipStream);
     }
 }
开发者ID:GregPerez83,项目名称:kudu,代码行数:10,代码来源:ZipArchiveExtensions.cs


示例7: AddTestResultFileIfItExists

 private void AddTestResultFileIfItExists(FileInfoBase fileInfoBase)
 {
     if (fileInfoBase.Exists)
     {
         this.testResultsFiles.Add(fileInfoBase);
     }
     else
     {
         Log.Error("A test result file could not be found, it will be skipped: {0}", fileInfoBase.FullName);
     }
 }
开发者ID:MikeThomas64,项目名称:pickles,代码行数:11,代码来源:Configuration.cs


示例8: StreamFile

        private void StreamFile(FileInfoBase file)
        {
            // Set varaibles.
            const int bufferReadSize = 1024 * 8;
            var fileSize = file.Length;
            long start = 0;
            long end = fileSize - 1;

            // Check if range specified.
            if(Request.Headers.AllKeys.Contains("Range"))
            {
                // Extract range details.
                var range = Request.Headers.Get("Range");
                var rangeRegex = new Regex(@"^bytes=(\d+)-(\d*)", RegexOptions.IgnoreCase);
                var match = rangeRegex.Match(range);

                // Extract start.
                if(match.Groups.Count>1 && !string.IsNullOrEmpty(match.Groups[1].Value))
                {
                    long.TryParse(match.Groups[1].Value, out start);
                }

                // Extract end.
                if(match.Groups.Count>2 && !string.IsNullOrEmpty(match.Groups[2].Value))
                {
                    long.TryParse(match.Groups[2].Value, out end);
                }

                // Check if Offset is valid.
                if(start < 0 || start > end)
                {
                    Response.StatusCode = 416;
                    Response.StatusDescription = "Requested Range Not Satisfiable";
                    Response.End();
                    return;
                }
            }

            if(start != 0)
            {
                Response.StatusCode = 206;
                Response.StatusDescription = "Partial Content";
            }

            // Set headers.
            Response.ContentType = file.Name.ResoveContentType();
            Response.AddHeader("Accept-Ranges", "bytes");
            Response.AddHeader("Content-Range", string.Format("bytes {0}-{1}/{2}", start, end, fileSize));
            Response.AddHeader("Content-Length", (end + 1 - start).ToString());

            // Transmit the file.
            Response.OutputStream.TransmitFile(file, start, (end + 1 - start));
            Response.End();
        }
开发者ID:dipeshc,项目名称:MediaPod,代码行数:54,代码来源:TVShowService.cs


示例9: Load

 public XDocument Load(FileInfoBase fileInfo)
 {
   XDocument document;
   using (var stream = fileInfo.OpenRead())
   {
     XmlReader xmlReader = XmlReader.Create(stream);
     document = XDocument.Load(xmlReader);
     stream.Close();
   }
   return document;
 }
开发者ID:Jaykul,项目名称:pickles,代码行数:11,代码来源:XDocumentLoader.cs


示例10: Create

        public static ICsvWriter Create(FileInfoBase fileInfo)
        {
            var csvConfiguration = new CsvConfiguration
            {
                Delimiter = ";",
                HasHeaderRecord = true
            };

            var streamWriter = new StreamWriter(fileInfo.OpenWrite(), Encoding.UTF8);
            return new CsvHelper.CsvWriter(streamWriter, csvConfiguration);
        }
开发者ID:ArneD,项目名称:unique-file-records-comparer,代码行数:11,代码来源:CsvWriter.cs


示例11: ReadResultsFile

 private List<Feature> ReadResultsFile(FileInfoBase testResultsFile)
 {
     List<Feature> result;
       using (var stream = testResultsFile.OpenRead())
       {
     using (var reader = new StreamReader(stream))
     {
       result = JsonConvert.DeserializeObject<List<Feature>>(reader.ReadToEnd());
     }
       }
       return result;
 }
开发者ID:pianovelty,项目名称:pickles,代码行数:12,代码来源:CucumberJsonSingleResults.cs


示例12: ListFile

        static void ListFile(FileInfoBase file)
        {
            if (!file.Exists)
            {
                throw new FileNotFoundException(file.FullName + " does not exist.");
            }

            Console.WriteLine();
            Console.WriteLine(" Directory of {0}", file.Directory.FullName.TrimEnd('\\'));
            Console.WriteLine();
            Console.WriteLine(String.Format("{0} {1,17} {2}", ToDisplayString(file.LastWriteTime), file.Length.ToString("#,##0"), file.Name));
            Console.WriteLine(String.Format("{0,16} File(s) {1,14} bytes", 1, file.Length.ToString("#,##0")));
        }
开发者ID:projectkudu,项目名称:KuduVfs,代码行数:13,代码来源:Program.cs


示例13: ExtractDetails

        public bool ExtractDetails(FileInfoBase showFile)
        {
            // Run AtomicParsley to get details.
            var details = new Dictionary<string, string>();
            if(!AtomicParsley.AtomicParsley.ExtractDetails(showFile.FullName, out details))
            {
                return false;
            }

            // Extract the details out of the output.
            if(!details.ContainsKey("tvsh") || !details.ContainsKey("tves"))
            {
                return false;
            }

            // Set default values.
            ShowName = details["tvsh"];
            SeasonNumber = null;
            EpisodeNumber = Convert.ToInt32(details["tves"]);
            EpisodeName = null;
            AiredDate = null;
            Overview = null;
            TVNetwork = null;
            Artworks = null;

            // Set optional values.
            if(details.ContainsKey("tvsn"))
            {
                SeasonNumber = Convert.ToInt32(details["tvsn"]);
            }
            if(details.ContainsKey("@nam"))
            {
                EpisodeName = details["@nam"];
            }
            if(details.ContainsKey("@day"))
            {
                AiredDate = DateTime.Parse(details["@day"]);
            }
            if(details.ContainsKey("@desc"))
            {
                Overview = details["desc"];
            }
            if(details.ContainsKey("tvnn"))
            {
                TVNetwork = details["tvnn"];
            }

            HasDetails = true;
            return true;
        }
开发者ID:dipeshc,项目名称:MediaOrganiser,代码行数:50,代码来源:ShowDetailsAtomic.cs


示例14: IsRelevant

        public bool IsRelevant(FileInfoBase fileInfo)
        {
            if (fileInfo == null)
            {
                return false;
            }

            string extension = fileInfo.Extension.ToUpperInvariant();

            if (this.validExtensions.Contains(extension))
            {
                return true;
            }

            return false;
        }
开发者ID:Jaykul,项目名称:pickles,代码行数:16,代码来源:ImageFileDetector.cs


示例15: LoadFile

        /// <summary>
        /// Loads a file from the file name.
        /// </summary>
        /// <param name="fileInfo">The file info.</param>
        /// <returns>The file's content.</returns>
        protected string LoadFile(FileInfoBase fileInfo)
        {
            // Data validation
            if (null == fileInfo)
                throw new ArgumentNullException("fileInfo");

            // Load the file content
            MemoryStream memoryStream = new MemoryStream();
            using (StreamReader streamReader = new StreamReader(fileInfo.OpenRead()))
            using (var fileWriter = new StreamWriter(memoryStream))
            {
                fileWriter.Write(streamReader.ReadToEnd());
            }

            // Read the code snippet from the file
            return Encoding.UTF8.GetString(memoryStream.ToArray());
        }
开发者ID:defrancea,项目名称:Projbook,代码行数:22,代码来源:DefaultSnippetExtractor.cs


示例16: WorkingTVShow

 public WorkingTVShow(ITVShow tvShow, FileInfoBase file)
 {
     File = file;
     Definition = tvShow.Definition;
     TVShowName = tvShow.TVShowName;
     SeasonNumber = tvShow.SeasonNumber;
     EpisodeNumber = tvShow.EpisodeNumber;
     Name = tvShow.Name;
     Description = tvShow.Description;
     Genres = tvShow.Genres;
     Cast = tvShow.Cast;
     Directors = tvShow.Directors;
     Screenwriters = tvShow.Screenwriters;
     ReleaseDate = tvShow.ReleaseDate;
     Network = tvShow.Network;
     Artwork = tvShow.Artwork;
 }
开发者ID:dipeshc,项目名称:MediaPod,代码行数:17,代码来源:RemuxEncodeMetadataAndAddToLibrary.cs


示例17: IsMarkdownFile

        public bool IsMarkdownFile(FileInfoBase file)
        {
            switch (file.Extension.ToLowerInvariant())
            {
                case ".markdown":
                case ".mdown":
                case ".mkdn":
                case ".md":
                case ".mdwn":
                case ".mdtxt":
                case ".mdtext":
                case ".text":
                case ".txt":
                    return true;
            }

            return false;
        }
开发者ID:eduaquiles,项目名称:pickles,代码行数:18,代码来源:RelevantFileDetector.cs


示例18: ExtractDefinition

            private static Definition ExtractDefinition(FileInfoBase file)
            {
                var streams = new MediaStreamsExtractor(file).Extract();
                var videoStream = streams.Where(stream => stream is MediaStreamsExtractor.IVideoStream).Select(stream => ((MediaStreamsExtractor.IVideoStream) stream).Height).OrderByDescending(h => h);
                if(!videoStream .Any())
                {
                    return Definition.Unknown;
                }

                var height = videoStream.First();
                if(height >= 1080)
                {
                    return Definition.HD1080;
                }
                else if(height >= 720)
                {
                    return Definition.HD720;
                }
                return Definition.SD;
            }
开发者ID:dipeshc,项目名称:MediaPod,代码行数:20,代码来源:UnorganisedLibrary.cs


示例19: CreateFromFileName

        public static IFileReader CreateFromFileName(FileInfoBase fileInfoBase)
        {
            if (IsCsvFile(fileInfoBase.FullName))
            {
                var reader = new CsvHelper.CsvReader(new StreamReader(fileInfoBase.OpenRead()), new CsvConfiguration
                {
                    HasHeaderRecord = true,
                    Delimiter = ";"
                });

                return new CsvReader(reader);
            }

            if (IsExcelFile(fileInfoBase.FullName))
            {
                var excelReader = ExcelReaderFactory.CreateOpenXmlReader(fileInfoBase.Open(FileMode.Open, FileAccess.Read));
                excelReader.IsFirstRowAsColumnNames = true;
                return new ExcelReader(excelReader);
            }

            throw new InvalidOperationException();
        }
开发者ID:ArneD,项目名称:unique-file-records-comparer,代码行数:22,代码来源:FileReaderFactory.cs


示例20: CopyInternalAsync

        static Task CopyInternalAsync(IFileSystem srcFileSystem, FileInfoBase srcFileInfo, IFileSystem dstFileSystem, FileInfoBase dstFileInfo)
        {
            return TaskHelpers.RunSynchronously(() =>
            {
                if (srcFileInfo.Exists && dstFileInfo.Exists && srcFileInfo.LastWriteTimeUtc == dstFileInfo.LastWriteTimeUtc)
                {
                    lock (_semaphore)
                    {
                        Console.WriteLine("          File up-to-date from \"" + srcFileInfo.FullName + "\" to \"" + dstFileInfo.FullName + "\"");
                    }
                }
                else
                {
                    byte[] bytes = srcFileSystem.File.ReadAllBytes(srcFileInfo.FullName);
                    if (dstFileSystem is FileSystem)
                    {
                        EnsureDirectory(Path.GetDirectoryName(dstFileInfo.FullName));
                    }
                    dstFileSystem.File.WriteAllBytes(dstFileInfo.FullName, bytes);

                    if (dstFileSystem is FileSystem)
                    {
                        dstFileInfo.LastWriteTimeUtc = srcFileInfo.LastWriteTimeUtc;
                    }
                    else if (srcFileSystem is FileSystem)
                    {
                        srcFileInfo.LastWriteTimeUtc = dstFileSystem.FileInfo.FromFileName(dstFileInfo.FullName).LastWriteTimeUtc;
                    }

                    lock (_semaphore)
                    {
                        Console.WriteLine("{0,12} bytes copied from \"" + srcFileInfo.FullName + "\" to \"" + dstFileInfo.FullName + "\"", bytes.Length.ToString("#,##0"));
                        ++_totalFiles;
                        _totalBytes += bytes.Length;
                    }
                }
            });
        }
开发者ID:projectkudu,项目名称:KuduVfs,代码行数:38,代码来源:Program.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TestingHelpers.MockFileSystem类代码示例发布时间:2022-05-26
下一篇:
C# Abstractions.DirectoryInfoBase类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap