本文整理汇总了C#中System.IO.StreamReader.Lines方法的典型用法代码示例。如果您正苦于以下问题:C# StreamReader.Lines方法的具体用法?C# StreamReader.Lines怎么用?C# StreamReader.Lines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StreamReader
的用法示例。
在下文中一共展示了StreamReader.Lines方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public DisassembledIl Read(Pathname path)
{
using (StringWriter writer = new StringWriter())
{
using (StreamReader reader = new StreamReader(path.AsString))
{
foreach (string line in reader.Lines())
{
writer.WriteLine(line);
}
}
return new DisassembledIl(writer.ToString());
}
}
示例2: Lines
///<summary>Streams the rows returned by the FileStream one at a time.</summary>
public static IEnumerable<string> Lines(this FileStream me)
{
Contract.Requires(me != null);
using(var reader = new StreamReader(me))
{
return reader.Lines().ToList();
}
}
示例3: FindValidWords
// Decided it would be more efficient to use
// the list of possible valid words from the dictionary and evaluate them then
// against the keyboard Knight Move permutations using PLinq.
private static string[] FindValidWords(Character[,] characterSet)
{
string fileName = @"..\..\Data\SINGLE.TXT";
string[] filteredDictionary; // PLinq is more efficient with arrays.
Keyboard board = new Keyboard(characterSet, SEARCH_DEPTH);
using (StreamReader sr = new StreamReader(fileName))
{
filteredDictionary = sr.Lines().ToArray();
}
string[] finalWordList = (from word in filteredDictionary.AsParallel()
.WithMergeOptions(ParallelMergeOptions.NotBuffered)
.WithDegreeOfParallelism(Environment.ProcessorCount)
where board.ValidateWord(new Word(word))
select word).ToArray();
return finalWordList;
}
示例4: ExecuteTask
/// <summary>
/// Submits the form.
/// </summary>
protected override void ExecuteTask()
{
var wc = new WebClient();
var nvc = CreateNameValueCollection(Fields);
Log(Level.Info, "POSTing to '{0}' with {1} form fields.", Action, nvc.Count);
var result = wc.UploadValues(Action, "POST", nvc);
using (var resultStream = new MemoryStream(result))
using (var sr = new StreamReader(resultStream))
{
foreach (var line in sr.Lines())
{
Log(Level.Verbose, line);
}
}
}
示例5: GetHostfileContent
/// <summary>Get the content of hosts file (or host file profile) with the specified <paramref name="filePath"/>.</summary>
/// <param name="filePath">The path to the hosts file or an host file profile.</param>
/// <returns>All lines from the hostfile with the specified <paramref name="filePath"/>.</returns>
public List<string> GetHostfileContent(string filePath)
{
this.VerifyFile(filePath);
using (var stream = new StreamReader(filePath))
{
return (from line in stream.Lines() select line).ToList();
}
}
示例6: LinesTest
public void LinesTest()
{
using (var sr = new StreamReader(_testStringsFile, true))
Assert.AreEqual(sr.Lines().Count(), 10);
}