C# File.ReadLines的代码示例
通过代码示例来学习C# File.ReadLines方法
通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。
File.ReadLines是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的File.ReadLines() 已经帮大家高亮显示了,大家可以重点学习File.ReadLines() 方法的写法,从而快速掌握该方法的应用。
File.ReadLines的代码示例1 - TryReadLastRefLogEntry()
using System.IO; ///
/// 'git ref-log' doesn't work if the repo is corrupted, so parsing reflogs seems like the only solution. /// /// A full symbolic ref name. eg. HEAD, refs/remotes/origin/HEAD, refs/heads/master private static bool TryReadLastRefLogEntry(Enlistment enlistment, string fullSymbolicRef, out RefLogEntry refLog, out string error) { string refLogPath = Path.Combine(enlistment.WorkingDirectoryBackingRoot, GVFSConstants.DotGit.Logs.Root, fullSymbolicRef); if (!File.Exists(refLogPath)) { refLog = null; error = "Could not find reflog for ref '" + fullSymbolicRef + "'"; return false; } try { string refLogContents = File.ReadLines(refLogPath).Last(); if (!RefLogEntry.TryParse(refLogContents, out refLog)) { error = "Last ref log entry for " + fullSymbolicRef + " is unparsable."; return false; } } catch (IOException ex) { refLog = null; error = "IOException while reading reflog '" + refLogPath + "': " + ex.Message; return false; } error = null; return true; }
开发者ID:microsoft,项目名称:VFSForGit,代码行数:35,代码来源:GitHeadRepairJob.cs
在TryReadLastRefLogEntry()方法中,File的代码示例类中的ReadLines的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
File.ReadLines的代码示例2 - Main()
using System.IO; static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); execDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); folderDir = execDirectory; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var client = new GitHubClient(new ProductHeaderValue("ST_UpdateTool")); GetReleases(client).Wait(); string versionTxt = Path.Combine(execDirectory, "Version.txt"); if (!File.Exists(versionTxt)) File.Create(versionTxt); string[] versionInfo = File.ReadLines(versionTxt).ToArray(); string ProgramVersion = ""; string CompileDate = ""; string CommitInfo = ""; if (versionInfo.Length >= 3) { ProgramVersion = versionInfo[0]; CompileDate = versionInfo[1]; CommitInfo = versionInfo[2]; } foreach (string arg in args) { switch (arg) { case "-d": case "--download": Download(CompileDate); break; case "-i": case "--install": Install(); break; case "-b": case "--boot": Boot(); Environment.Exit(0); break; case "-e": case "--exit": Environment.Exit(0); break; } } Console.Read(); }
开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:55,代码来源:Program.cs
在Main()方法中,File的代码示例类中的ReadLines的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
File.ReadLines的代码示例3 - ExpandResponseFiles()
using System.IO; private static string[] ExpandResponseFiles(string[] args) { var expandedArgs = new List
(); foreach (var arg in args) { if (!arg.StartsWith("@", StringComparison.Ordinal)) { expandedArgs.Add(arg); } else { var fileName = arg.Substring(1); expandedArgs.AddRange(File.ReadLines(fileName)); } } return expandedArgs.ToArray(); }
开发者ID:aspnet,项目名称:Razor,代码行数:20,代码来源:Application.cs
在ExpandResponseFiles()方法中,File的代码示例类中的ReadLines的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
File.ReadLines的代码示例4 - LoadIgnoredWordsFile()
using System.IO; ///
/// This is used to load the ignored words file /// private void LoadIgnoredWordsFile() { ignoredWords.Clear(); if(File.Exists(ignoredWordsFile)) { try { foreach(string word in File.ReadLines(ignoredWordsFile)) if(!String.IsNullOrWhiteSpace(word)) ignoredWords.Add(word.Trim()); } catch(Exception ex) { // Ignore exceptions. Not much we can do, we'll just not ignore anything by default. System.Diagnostics.Debug.WriteLine(ex); } } }
开发者ID:EWSoftware,项目名称:SHFB,代码行数:24,代码来源:GlobalDictionary.cs
在LoadIgnoredWordsFile()方法中,File的代码示例类中的ReadLines的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
本文中的File.ReadLines方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。