我的循环中有问题。我将一个文本文档拆分为x个较小的文档。问题在于,即使它们应该一样大,文档也越来越大。创建第三个或第四个Textdocument时,我得到了SystemOutofMemory异常(这是逻辑上的)。
有人在我的循环中看到错误吗?
我已经尝试过
Sub splitFile()
Dim SplitNumber As Long = Textlaenge / Splitanzahl
Dim endindex As Long = 0
For i As Int64 = 1 To Splitanzahl
Dim nab As String = inhalt.Substring(endindex, SplitNumber * i)
Dim index As Long = inhalt.IndexOf("><", nab.Count)
Dim FinalString As String = inhalt.Substring(endindex, index + 1)
endindex = index + 1
If i = 1 Then
FinalString = FinalString & "</ifapRohdaten>"
Else
'FinalString = "TEST" & FinalString & "</ifapRohdaten>"
End If
If i = Splitanzahl Then
'FinalString = "TEST" & FinalString
End If
'Hier wird der text in eine Textdatei geschrieben und unter dem
angegebenden Pfad abgespeichert
Dim objStreamWriter As StreamWriter
'Pass the file path and the file name to the StreamWriter
constructor.
objStreamWriter = New StreamWriter("C:\Users\jd\Desktop\" & "Artikel" & i & ".xml")
'Write a line of text.
objStreamWriter.Write(FinalString)
'Close the file.
objStreamWriter.Close()
objStreamWriter = Nothing
Next