是否可以使用数组将多个文本框写入文本文件中的多行而不改变文本文件的其余部分?我用的是:
'Write co-ordinates into KML file
Dim line() As String = System.IO.File.ReadAllLines([filepath]A.kml")
line(19) = A2.Text
System.IO.File.WriteAllLines("[filepath]A.kml", line)
但是它会替换它下面的内容。
谢谢
你可以试试:
Dim List As New List(Of String)
Dim Writer As New StreamWriter(<filepath+filename>)
Dim Reader As New StreamReader(<filetoread>)
Do Until Reader.EndOfStream
List.Add(Reader.ReadLine())
Loop
List(19) = A2.Text
For Each s As String In List
Writer.WriteLine(s)
Next
Writer.Close()