trying to convert a VB6 program just now, it uses FILESYSTEMOBJECT to create a TEXTSTREAM for appending, and once opened it is kept open for the whole process as this is the method of writing to the LOG files. The recommended method seems to be SYSTEM.IO for a replacement.
All the info I can find (FILES and STREAMWRITER) all seem to Open / Write / Close, the file every time we want to append to it. We are looking to keep the file open and the stream active to remove any overheads in the OPEN / CLOSE for each write. New to VB.NET so any pointers are greatly appreciated.
One constraint we have is that we can't build up multiple lines of text and then write them all at once, the business need it written to after each action
I have experimented with USING - END USING for TEXTSTREAMS and FILE.CREATE / APPENDALLText
You can definitely use a StreamWriter. Just don't close it until you're ready to.
If you need to access it from multiple methods, then declare it class/form level and it'll stay open for the lifetime of the app, or until you explicitly close it:
*The above has zero exception handling, which should always be added when dealing with files.