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


C# Abstractions.FileInfoBase类代码示例

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


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


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