Hello all,
I'm currently migrating from VB6 to VB.NET (2008) an application.
I have the following questions regarding r/w of text files:
1. In VB6 application, I have a log file and a "write to log" function, that opens, write and close the log file each time that function is called. What is considered better in .NET ? Open this file when the application is started, keeping it opened while the app is running, just writing to the file when the "write to log" function is called and close the file when the app is terminated, or the second choice - Just as I have in my VB6 app - open+write+close each time the function is called?
2. I've found many examples of r/w in VB.NET. Currently, I'm using this one:
My question is - What is considered the most efficient and performance economical way when I have a function that read and write to a text file many times during one running of the app?
Thanks in advance!!
I'm currently migrating from VB6 to VB.NET (2008) an application.
I have the following questions regarding r/w of text files:
1. In VB6 application, I have a log file and a "write to log" function, that opens, write and close the log file each time that function is called. What is considered better in .NET ? Open this file when the application is started, keeping it opened while the app is running, just writing to the file when the "write to log" function is called and close the file when the app is terminated, or the second choice - Just as I have in my VB6 app - open+write+close each time the function is called?
2. I've found many examples of r/w in VB.NET. Currently, I'm using this one:
Code:
Dim oFile As New FileStream("a.txt", FileMode.Append, FileAccess.Write)
Dim oWrite As New StreamWriter(oFile)
oWrite.WriteLine(Now)
oWrite.Close()
My question is - What is considered the most efficient and performance economical way when I have a function that read and write to a text file many times during one running of the app?
Thanks in advance!!