vb.net - Why won't this write to my text file in Visual Basic? -
i have been trying , searching hours , telling me doing, why won't code write text file? no errors being thrown, data won't write
dim newday boolean = true dim attendance streamwriter if newday = true try attendance = file.appendtext("attendancelog.txt") attendance.writeline(date.today.tostring("dd/mm/yyyy")) newday = false catch messagebox.show("file access denied", "error") end try end if
when using streamwriter, send put in queue avoid writing file everytime new part needs appended (which inefficient large files logs).
to process queue, call streamwriter.flush().
but discouraged. should instead use streamwriter.close() @ end, automatically , disposes object memory, too.
dim newday boolean = true dim attendance streamwriter if newday = true try attendance = file.appendtext("attendancelog.txt") attendance.writeline(date.today.tostring("dd/mm/yyyy")) attendance.close() newday = false catch messagebox.show("file access denied", "error") end try end if
Comments
Post a Comment