VB.NET質問スレ (Part20)
at TECH
137:デフォルトの名無しさん
07/03/15 09:51:10
>>125 こんなのでどうか
Public Function ReadTailLines(ByVal filename As String, ByVal lineCount As Integer)
Dim sep() As String = {vbCrLf}
Using ifs As IO.FileStream = IO.File.OpenRead(filename)
Dim allBuf As New List(Of Byte)
Dim len As Integer = lineCount * 100
Dim pos As Long = ifs.Length
Dim lines() As String
Do
pos -= len
If pos < 0 Then
len += pos
pos = 0
End If
Dim tmpBuf(len) As Byte
ifs.Seek(pos, IO.SeekOrigin.Begin)
ifs.Read(tmpBuf, 0, len)
allBuf.InsertRange(0, tmpBuf)
lines = Text.Encoding.Default.GetString(allBuf.ToArray(), 0, allBuf.Count).Split(sep, StringSplitOptions.None)
Loop While pos > 0 And lines.Length < lineCount
(続く)
次ページ続きを表示1を表示最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
4336日前に更新/125 KB
担当:undef