punkwalrus (punkwalrus) wrote,
punkwalrus
punkwalrus

VB.NET - Writing to a file

I kind of already knew this, but in case you want a quick and dirty reference, here's what I did to write to one of my logs:  

'# Declare a file, then declare a process to write to it 

Dim oLogFile As System.IO.File
Dim oLogWrite As System.IO.StreamWriter 

'# Connect the two to open it 

oLogWrite = oLogFile.AppendText(strLogFile)

 '# Write to the file my timestamp and alert strings 

oLogWrite.WriteLine(strTimestamp & strAlert)

 '# Close (important, I have found, because if you end
'  the program without closing your files, random data

'  gets lost... yeeee)
 

oLogWrite.Close()

Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments