Created
October 17, 2013 03:10
-
-
Save traktraktrugui/7018700 to your computer and use it in GitHub Desktop.
Get a last line from a text file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
string fileName = @"c:\windows\setupapi.log"; | |
byte[] array = new byte[100]; | |
using (FileStream fs = new FileStream(fileName, FileMode.Open)) | |
{ | |
if (fs.CanSeek && fs.Length > 100) | |
{ | |
fs.Position = fs.Length - 100; | |
fs.Read(array, 0, 100); | |
} | |
} | |
Encoding enc = new ASCIIEncoding(); | |
string line = enc.GetString(array); | |
Console.Write(line); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment