1
我已經通讀了如何使用streamWriter Preserving existing text when writing to file 然而,即使我的代碼幾乎相同,無論我什麼都不做,也不會寫入文件。這裏是代碼:用流寫入器寫行到文件
Private Sub Main()
Dim todaysdate As String = DateTime.Today
todaysdate = todaysdate.Replace("/", ".")
Dim todayFile As String = "dated\" & todaysdate & ".txt."
'this just creates the name and filepath that i want my file to be located at
If File.Exists(todayFile) = False Then
Dim Day As StreamWriter
Day = New StreamWriter(todayFile, True)
Day.WriteLine("sandwhich")
end if
end sub
所以是的,這真的只是創建文件,但是當我打開該文件是空的(有沒有問題,該文件是用正確的時間和地點製造)!有什麼建議麼?