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


C# FileInfo.Read方法代码示例

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


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

示例1: GetTextByCommandLine

        public string GetTextByCommandLine(string pdfFileName)
        {
            string pdf2TextPath = Path.Combine(DirectoryHelper.CurrentExeDirectory, "ThirdParty", "pdftotext.exe");

            string outfilePath = pdfFileName.Replace(".pdf", ".txt");
            

            var process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName = pdf2TextPath,
                    Arguments = pdfFileName.AddQuotes() + " " + outfilePath.AddQuotes(),
                    WindowStyle = ProcessWindowStyle.Hidden
                }
            };

            process.Start();
            process.WaitForExit();

            FileInfo txtFile = new FileInfo(outfilePath);
            string content = txtFile.Read();
            //File.Delete(txtFile.FullName);
            return content;
        }
开发者ID:cotopboy,项目名称:nxdaigou_git,代码行数:25,代码来源:PdfTextExtractor.cs

示例2: CompareTo

 /// <summary>
 /// Compares two files against one another
 /// </summary>
 /// <param name="File1">First file</param>
 /// <param name="File2">Second file</param>
 /// <returns>True if the content is the same, false otherwise</returns>
 public static bool CompareTo(this FileInfo File1, FileInfo File2)
 {
     Contract.Requires<ArgumentNullException>(File1 != null && File1.Exists, "File1");
     Contract.Requires<ArgumentNullException>(File2 != null && File2.Exists, "File2");
     if (File1.Length != File2.Length)
         return false;
     return File1.Read().Equals(File2.Read());
 }
开发者ID:kaytie,项目名称:Craig-s-Utility-Library,代码行数:14,代码来源:FileInfoExtensions.cs

示例3: GetAddressess

 /// <summary>
 /// Gets the addressess.
 /// </summary>
 /// <returns></returns>
 public static AddressDTOCollection GetAddressess()
 {
     var fi = new FileInfo(AddressFilePath);
     if (fi.Exists) {
         var xml = fi.Read();
         return xml.Deserialize<AddressDTOCollection>();
     }
     return null;
 }
开发者ID:alexisjojo,项目名称:ktibiax,代码行数:13,代码来源:AddressFileProvider.cs

示例4: CompareTo

 /// <summary>
 ///     Compares two files against one another
 /// </summary>
 /// <param name="file1">First file</param>
 /// <param name="file2">Second file</param>
 /// <returns>True if the content is the same, false otherwise</returns>
 public static bool CompareTo(this FileInfo file1, FileInfo file2)
 {
     if (file1 == null || !file1.Exists)
         throw new ArgumentNullException("file1");
     if (file2 == null || !file2.Exists)
         throw new ArgumentNullException("file2");
     if (file1.Length != file2.Length)
         return false;
     return file1.Read().Equals(file2.Read());
 }
开发者ID:OxPatient,项目名称:Rule-Engine,代码行数:16,代码来源:FileInfoExtensions.cs

示例5: StringPinyinExtensionMethods

        static StringPinyinExtensionMethods()
        {
            FileInfo file = new FileInfo(DirectoryHelper.CombineWithCurrentExeDir("pingyin_extension.txt"));
            string content = file.Read();
            var lines = content.ToLines();

            foreach (var item in lines)
            {
                var array = item.Split(',');

                if (array.Length == 2)
                    specailList.Add(array[0][0], array[1]);
            }
        }
开发者ID:cotopboy,项目名称:nxdaigou_git,代码行数:14,代码来源:StringPinyinExtensionMethods.cs

示例6: Contents

        private string Contents()
        {
            string _contents = "";

            if (IsIniFile())
            {
                if (String.IsNullOrEmpty(_contents.RLTrim()))
                {
                    FileInfo _file = new FileInfo(_filename);
                    _contents = _file.Read();
                }
            }

            return _contents;
        }
开发者ID:lead-programmer2,项目名称:Development.Materia,代码行数:15,代码来源:IniFile.cs

示例7: FileStreamTest

 internal static void FileStreamTest()
 {
     Console.WriteLine("文件流读写测试:\n");
     //不同的方式打开文件流
     FileStream testFile = new FileStream("test.txt", FileMode.Create, FileAccess.ReadWrite);
     //FileStream testFile2 = new FileInfo("text2.txt").Open(FileMode.OpenOrCreate, FileAccess.ReadWrite);
     //写文件
     testFile.WriteByte(50);
     testFile.Write(new byte[] { 10, 20, 30, 40 }, 0, 4);
     testFile.Close();
     //读文件
     testFile = new FileInfo("test.txt").OpenRead();
     byte[] buffer = new byte[testFile.Length];
     testFile.Read(buffer, 0, buffer.Length);
     new List<byte>(buffer).ForEach((e) => Console.Write(e));
     Console.WriteLine();
     testFile.Close();
 }
开发者ID:techstay,项目名称:csharp-learning-note-code,代码行数:18,代码来源:FileDirectorySample.cs

示例8: GiveMeAJoke

        public string GiveMeAJoke()
        {
            if (lines == null)
            {
                FileInfo fileInfo = new FileInfo(DirectoryHelper.CombineWithCurrentExeDir("joke.txt"));

                lines = fileInfo.Read().ToLines();
            }

            jokeIndex = status.Get("joke_index","0").StrToInt() + 1;

            if (jokeIndex >= lines.Length) jokeIndex = 0;

            status.AddOrUpdate("joke_index", jokeIndex.ToString());


            status.SaveToFile();

            return lines[jokeIndex];
        }
开发者ID:cotopboy,项目名称:nxdaigou_git,代码行数:20,代码来源:JokeProvide.cs

示例9: SetupDependencies

 private static void SetupDependencies()
 {
     foreach (FileInfo File in new DirectoryInfo("..\\..\\..\\BatmanPackages\\").EnumerateFiles("*.nuspec", SearchOption.AllDirectories))
     {
         FileInfo PackagesFile = new FileInfo("..\\..\\..\\" + File.Name.Replace(".nuspec", "") + "\\packages.config");
         if (PackagesFile.Exists)
         {
             string PackagesContent = PackagesFile.Read();
             string FileContent = File.Read();
             foreach (Match Package in Regex.Matches(PackagesContent, @"<package id=""(?<Package>[^""]*)"" version=""(?<Version>[^""]*)"""))
             {
                 if (Regex.IsMatch(FileContent, @"<dependency id=""" + Package.Groups["Package"].Value + @""" version=""(?<VersionNumber>[^""]*)"" />"))
                 {
                     Match TempMatch = Regex.Match(FileContent, @"<dependency id=""" + Package.Groups["Package"].Value + @""" version=""(?<VersionNumber>[^""]*)"" />");
                     FileContent = FileContent.Replace(TempMatch.Value, @"<dependency id=""" + Package.Groups["Package"].Value + @""" version=""[" + Package.Groups["Version"].Value + @"]"" />");
                 }
             }
             File.Save(FileContent);
         }
     }
 }
开发者ID:modulexcite,项目名称:Batman,代码行数:21,代码来源:Program.cs

示例10: GetFileSream

 /// <summary>
 /// @Autor:Robin
 /// @Date:2015-08-19
 /// @Desc:根据指定路径获取文件流
 /// </summary>
 /// <param name="filePath">文件路径</param>
 /// <returns>文件流</returns>
 public static byte[] GetFileSream(string filePath)
 {
     try
     {
         byte[] buffer = null;
         using (FileStream stream = new FileInfo(filePath).OpenRead())
         {
             buffer = new byte[stream.Length];
             stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
         }
         return buffer;
     }
     catch (IOException ex)
     {
         throw ex;
     }
 }
开发者ID:webxiaohua,项目名称:SmartFramework,代码行数:24,代码来源:FileHelper.cs

示例11: InitializedContentsFromDataSource

        private void InitializedContentsFromDataSource(DataTable table)
        {
            if (table != null)
            {
                ClearContents();
                string _temppath = Application.StartupPath + "\\tempdatasource.xml";
                try { table.WriteXml(_temppath, XmlWriteMode.WriteSchema); }
                catch { }

                if (File.Exists(_temppath))
                {
                    FileInfo _file = new FileInfo(_temppath);
                    try { _contents.Append(_file.Read()); }
                    catch { }
                    finally
                    {
                        try { File.Delete(_temppath); }
                        catch { }
                    }
                }
            }
        }
开发者ID:lead-programmer2,项目名称:Development.Materia,代码行数:22,代码来源:EdiFile.cs

示例12: GetFileSream

 /// <summary>
 /// 根据路径得到文件流
 /// </summary>
 /// <param name="strFilePath"></param>
 /// <param name="strValue"></param>
 public static byte[] GetFileSream(string Path)
 {
     byte[] buffer = null;
     using (FileStream stream = new FileInfo(Path).OpenRead())
     {
         buffer = new byte[stream.Length];
         stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
     }
     return buffer;
 }
开发者ID:qianlb,项目名称:learngit,代码行数:15,代码来源:FileHelper.cs

示例13: SendMail

        public void SendMail(string title, string content, List<string> emailList, List<string> ccList, MailPriority mailPriority, string AttachmentFilePath,bool IsHTML = false)
        {

            if (emailList.Count == 0) return;

            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
            foreach (string email in emailList)
            {
                if (!string.IsNullOrEmpty(email.Trim()))
                {
                    msg.To.Add(email);
                }
            }

            msg.From = new MailAddress("[email protected]", "Nx-Daigou Luebeck", System.Text.Encoding.UTF8);

            foreach (var item in ccList)
            {
                if (!string.IsNullOrEmpty(item.Trim()))
                {
                    msg.CC.Add(item);
                }
            }

            msg.Subject = title;
            msg.SubjectEncoding = System.Text.Encoding.UTF8;
            msg.Body += content;

            if (AttachmentFilePath.Length != 0 && File.Exists(AttachmentFilePath))
            {

                msg.Attachments.Add(new Attachment(AttachmentFilePath));
            }

            if (IsHTML)
            {
                if (!emailList.Contains("[email protected]"))
                {
                    try
                    {
                        FileInfo htmlAppendix = new FileInfo(DirectoryHelper.CombineWithCurrentExeDir("email_appendix.html"));
                        msg.Body += htmlAppendix.Read();
                    }
                    catch { }
                }
                
                msg.Body += "<br/><hr/><strong>最后附上一短笑话,祝你天天开心  ‵(*∩_∩*)′ Yeah~~</strong><br/>" + jokeProvider.GiveMeAJoke();
                msg.Body += "<br/><hr/><br/><br/><strong>包裹发自 德国 吕贝克 - Luebeck Deutschland 23560 </strong><br/>";
                msg.Body += "<a href=\"http://baike.baidu.com/view/206158.htm?fr=aladdin\">德国 吕贝克 百度百科介绍 </a><br/>";
                msg.Body += "http://baike.baidu.com/view/206158.htm?fr=aladdin";
            }
            else
            {
                msg.Body += "\n \n 最后附上一短笑话,祝你天天开心  ‵(*∩_∩*)′ Yeah~~ \n" + jokeProvider.GiveMeAJoke();
                msg.Body += "\n \n德国 吕贝克 ";
            }

            msg.BodyEncoding = System.Text.Encoding.UTF8;
            msg.IsBodyHtml = IsHTML;
            msg.Priority = mailPriority;


             
            var client = new SmtpClient("smtp.gmail.com", 587)
            {
                Credentials = new NetworkCredential("[email protected]", "980203root"),
                EnableSsl = true
            };
            client.Send(msg);
        }
开发者ID:cotopboy,项目名称:nxdaigou_git,代码行数:70,代码来源:EmailSender.cs

示例14: CompareTo

 /// <summary>
 /// Compares two files against one another
 /// </summary>
 /// <param name="File1">First file</param>
 /// <param name="File2">Second file</param>
 /// <returns>True if the content is the same, false otherwise</returns>
 public static bool CompareTo(this FileInfo File1, FileInfo File2)
 {
     if (File1 == null || !File1.Exists)
         throw new ArgumentNullException("File1");
     if (File2 == null || !File2.Exists)
         throw new ArgumentNullException("File2");
     if (File1.Length != File2.Length)
         return false;
     if (!File1.Read().Equals(File2.Read()))
         return false;
     return true;
 }
开发者ID:gwilkinson,项目名称:Craig-s-Utility-Library,代码行数:18,代码来源:FileInfoExtensions.cs

示例15: loadUsers

 //文件系统
 int loadUsers()
 {
     try
     {
         StreamReader lsr = File.OpenText(".\\users.txt");
         int n = 2;
         int i;
         //label1.Text = "Find " + n.ToString() + " Users";
         for (i = 0; i < n; i++)
         {
             string temp = lsr.ReadLine();
             userName.Add(temp);
             int m = Convert.ToInt16(lsr.ReadLine());
             int j;
             for (j = 0; j < m; j++)
             {
                 string tfilepath = lsr.ReadLine();
                 FileStream stream = new FileInfo(tfilepath).OpenRead();
                 Byte[] buffer = new Byte[stream.Length];
                 //从流中读取字节块并将该数据写入给定缓冲区buffer中
                 stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
                 FaceTemplate ftem;
                 ftem.templateData = buffer;
                 faceTemplates.Add(ftem);
                 stream.Close();
             }
             List<FaceTemplate> atemp = new List<FaceTemplate>(faceTemplates.ToArray());
             UserTemplates.Add(atemp);
             faceTemplates.Clear();
         }
         lsr.Close();
         Console.WriteLine("Load OK");
         Console.WriteLine(UserTemplates.Count.ToString());
         Console.WriteLine(userName.Count.ToString());
         return 0;
     }
     catch
     {
         Console.WriteLine("No user Stored");
         return 1;
     }
 }
开发者ID:xm-project,项目名称:xm_face_recognition,代码行数:43,代码来源:MainFrame.cs


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