Socarsky
Well-known member
I can write a line of string in a text file but the text always write at the first line of the file which means I could not achieve to write a string at the under line of first or end of the file.
Private Sub MainForm_FormClosed(ByVal sender As Object, ByVal e As FormClosedEventArgs) Handles MyBase.FormClosed 'length of ful date digits Dim lenOfDate As Integer = 11 'mytxtFile is my text file to sum the previous number of data in it ' that how many kb/s data used when close the program Dim readNumber As New FileStream(mytxtFile, FileMode.Open) Dim br As New StreamReader(readNumber) 'to read number of data from the file to determine with date Dim lineInFile As String = br.ReadLine br.Close() 'to get numbers of data in the line after skiping date Dim countOfUsage As String = lineInFile.Substring(lenOfDate, ((lineInFile.Length) - (lenOfDate))) 'to convert string to integer Dim numbersInFile As Integer = CType(countOfUsage, Integer) 'to get read the file for operations Dim FS As New FileStream(mytxtFile, FileMode.OpenOrCreate, FileAccess.ReadWrite) Dim SW As New IO.StreamWriter(FS) 'to write date and some transmission's data count SW.WriteLine((Now.Date.ToString("yyyy-MM-dd") & "#") & (numbersInFile + collectRecieveCompute + _ collectSentCompute + collectTotall).ToString("###")) SW.Close() End Sub