参考
Dim dlg As New OpenFileDialog
dlg.Filter = "文本文件|*.txt"
If dlg.ShowDialog = DialogResult.OK Then
Dim fl As String = dlg.FileName
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(fl,System.Text.Encoding.Default)
Dim line As String
Dim sb As new StringBuilder
Dim i As Integer = 0
Dim j As Integer = 0
Do Until sr.EndOfStream
if i = 10 then '每份的行数
line = sb.Tostring
Dim f As String = SpecialFolder.DesktopDirectory & "\" & j & ".txt"
FileSys.WriteAllText(f, line, False, Encoding.Default)
j += 1
i = 0
sb.Clear()
line = ""
else
sb.AppendLine(sr.ReadLine)
i += 1
end if
Loop
line = sb.Tostring
if line > "" then
Dim f As String = SpecialFolder.DesktopDirectory & "\" & j & ".txt"
FileSys.WriteAllText(f, line, False, Encoding.Default)
end if
sr.Close()
Msgbox("拆分完成")
End If
[此贴子已经被作者于2020/6/26 13:52:03编辑过]