I need to keep a log file of activity in a simple text file. Ive done this in VB6, but Im guessing VB.NET has a single object I can use to write individual lines to a text file. Or is that not the case? Thanks for any recommendations you can give.
If I declare variables as either of those types, I see there are "Write" commands and other stuff, but Im not seeing how you assign a particular file to either of them to serve as the log file.
dim fs as filestream
fs = new filestream("C:\test.txt",filemode.append)
dim sw as streamwriter
sw = new streamwriter(fs)
sw.writeline("Poo")
sw.close
fs.close
That should do it. Check the intellisense when you type filemode. Youll get quite a few of options there.
Also, streamreaders work very similarly to streamwriters.
EDIT: Oh! filestream,streamwriter,streamreader and filemode are all things in the system.io namespace. So, they should be io.filestream, io.streamwriter, etc if you didnt import io.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.