2008年4月30日 星期三

VB.NET中寫入文件的同時,並覆蓋原文件內容


Dim strFilePath As String = "F:\\1.txt"
Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(strFilePath, False)
Dim temp As String = "1111111111111111111111111"
sw.WriteLine(temp)
sw.Flush()
sw.Close()
sw = Nothing


如果 Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(strFilePath, False)
改成 Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(strFilePath, true)
就是往後追加的

沒有留言: