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
所以是的,这真的只是创建文件,但是当我打开该文件是空的(有没有问题,该文件是用正确的时间和地点制造)!有什么建议么?