Esempio n. 1
0
 /// <summary>
 /// read each line and line number from a file.
 /// </summary>
 /// <param name="fi"></param>
 /// <param name="encoding"></param>
 /// <returns></returns>
 public static IEnumerable <(string line, int lineNum)> ReadLines(this FileInfo fi, Encoding?encoding = null)
 {
     using var reader = StreamReaderHelper.NewStreamReaderFromFileInfo(fi, encoding);
     foreach (var(line, lineNum) in reader.ReadLinesWithLineNumber())
     {
         yield return(line, lineNum);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Read all content from a file.
 /// </summary>
 /// <param name="fi"></param>
 /// <param name="encoding">read encoding</param>
 /// <returns>all content</returns>
 public static string ReadToEnd(this FileInfo fi, Encoding?encoding = null)
 {
     using var reader = StreamReaderHelper.NewStreamReaderFromFileInfo(fi, encoding);
     return(reader.ReadToEnd());
 }