File tree Expand file tree Collapse file tree 4 files changed +65
-0
lines changed Expand file tree Collapse file tree 4 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ // Description: C# Extension Methods Library to enhances the .NET Framework by adding hundreds of new methods. It drastically increases developers productivity and code readability. Support C# and VB.NET
2+ // Website & Documentation: https://github.com/zzzprojects/Z.ExtensionMethods
3+ // Forum: https://github.com/zzzprojects/Z.ExtensionMethods/issues
4+ // License: https://github.com/zzzprojects/Z.ExtensionMethods/blob/master/LICENSE
5+ // More projects: http://www.zzzprojects.com/
6+ // Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
7+ using System . IO ;
8+
9+ public static partial class Extensions
10+ {
11+ /// <summary>
12+ /// Skips the specified number of lines in a stream reader based on its current position.
13+ /// </summary>
14+ /// <param name="this">The stream reader.</param>
15+ /// <param name="skipCount">The number of lines to skip.</param>
16+ public static void SkipLines ( this StreamReader @this , int skipCount )
17+ {
18+ for ( var i = 0 ; i < skipCount && ! @this . EndOfStream ; i ++ )
19+ {
20+ @this . ReadLine ( ) ;
21+ }
22+ }
23+ }
Original file line number Diff line number Diff line change 110110 <Compile Include =" System.IO.FileInfo\FileInfo.WriteAllBytes.cs" />
111111 <Compile Include =" System.IO.FileInfo\FileInfo.WriteAllLines.cs" />
112112 <Compile Include =" System.IO.FileInfo\FileInfo.WriteAllText.cs" />
113+ <Compile Include =" System.IO.StreamReader\StreamReader.SkipLines.cs" />
113114 <Compile Include =" System.IO.Stream\Stream.ReadToEnd.cs" />
114115 <Compile Include =" System.IO.Stream\Stream.ToByteArray.cs" />
115116 <Compile Include =" System.IO.Stream\Stream.ToMD5Hash.cs" />
Original file line number Diff line number Diff line change 1+ // Description: C# Extension Methods Library to enhances the .NET Framework by adding hundreds of new methods. It drastically increases developers productivity and code readability. Support C# and VB.NET
2+ // Website & Documentation: https://github.com/zzzprojects/Z.ExtensionMethods
3+ // Forum: https://github.com/zzzprojects/Z.ExtensionMethods/issues
4+ // License: https://github.com/zzzprojects/Z.ExtensionMethods/blob/master/LICENSE
5+ // More projects: http://www.zzzprojects.com/
6+ // Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
7+ using System ;
8+ using System . IO ;
9+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
10+
11+ namespace Z . IO . Test
12+ {
13+ [ TestClass ]
14+ public class System_IO_StreamReader_SkipLines
15+ {
16+ [ TestMethod ]
17+ public void SkipLines ( )
18+ {
19+ var filePath = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory ,
20+ "Examples_System_IO_FileInfo_SkipLines.txt" ) ;
21+
22+ File . WriteAllLines ( filePath , new [ ]
23+ {
24+ "Line1" ,
25+ "Line2" ,
26+ "Line3" ,
27+ "Line4"
28+ } ) ;
29+
30+ using ( var file = File . OpenText ( filePath ) )
31+ {
32+ file . SkipLines ( 2 ) ;
33+ var nextLine = file . ReadLine ( ) ;
34+
35+ // Unit Test
36+ Assert . AreEqual ( "Line3" , nextLine ) ;
37+ }
38+ }
39+ }
40+ }
Original file line number Diff line number Diff line change 100100 <Compile Include =" System.IO.FileInfo\FileInfo.WriteAllBytes.cs" />
101101 <Compile Include =" System.IO.FileInfo\FileInfo.WriteAllLines.cs" />
102102 <Compile Include =" System.IO.FileInfo\FileInfo.WriteAllText.cs" />
103+ <Compile Include =" System.IO.StreamReader\StreamReader.SkipLines.cs" />
103104 <Compile Include =" System.IO.Stream\Stream.ReadToEnd.cs" />
104105 <Compile Include =" System.IO.Stream\Stream.ToByteArray.cs" />
105106 <Compile Include =" System.IO.Stream\Stream.ToMD5Hash.cs" />
You can’t perform that action at this time.
0 commit comments