读取每一行数据到数组中并按照固定的长度分割这行数据添加分隔符,再写出为一个新的txt文件
------解决思路----------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim path As String = "原文件路径"
Dim newPath As String = "新文件路径"
Dim splitLength As Integer = 3
Dim strData As String() = File.ReadAllLines(path)
Using sw As StreamWriter = File.CreateText(newPath)
For i As Integer = 0 To strData.GetUpperBound(0)
Dim index As Integer = 0
Dim newStr As String = ""
Dim modNum As Integer = strData(i).Length Mod splitLength
Dim splitNum As Integer = strData(i).Length / splitLength
If modNum > 0 Then
splitNum += 1
End If
For j As Integer = 1 To splitNum
If j = splitNum Then
If modNum > 0 Then
newStr += strData(i).Substring(index, modNum)
Else
newStr += strData(i).Substring(index, splitLength)
End If
Exit For
End If
newStr += strData(i).Substring(index, splitLength) + "我是分隔符"
index += splitLength
Next
sw.WriteLine(newStr)
Next
sw.Flush()
sw.Close()
End Using
End Sub
------解决思路----------------------
你要将自己的要求清晰的罗列清楚,不要说一半,然后又出来新的,不然,谁知道你想干什么。