hassan1404
Member
- Joined
- Mar 21, 2006
- Messages
- 6
- Programming Experience
- 1-3
Hi
I am haveing a small problem with writing to a file, I am trying to write the contents of a list box to a file but always end up with a blank line between each line of data.
Can anyone help? I have writtern the code that i am using below
Dim X As Integer
Dim fsStream As New FileStream("C:/Alarm.txt", FileMode.Truncate, FileAccess.Write)
Dim swWriter As New StreamWriter(fsStream)
X = 0
While X <= lstAlarm.Items.Count - 1
swWriter.WriteLine(lstAlarm.Items(X))
X = X + 1
End While
swWriter.Close()
Me.Close()
This gives a txt file like below only after it has truncated the file. The origanal file created is fine, and called back when the form loads (This file is created when the form is closed)
20:30 18/03/2006
12:34 18/03/2006
12:45 19/03/2006
Many thanks in advance Hassan
I am haveing a small problem with writing to a file, I am trying to write the contents of a list box to a file but always end up with a blank line between each line of data.
Can anyone help? I have writtern the code that i am using below
Dim X As Integer
Dim fsStream As New FileStream("C:/Alarm.txt", FileMode.Truncate, FileAccess.Write)
Dim swWriter As New StreamWriter(fsStream)
X = 0
While X <= lstAlarm.Items.Count - 1
swWriter.WriteLine(lstAlarm.Items(X))
X = X + 1
End While
swWriter.Close()
Me.Close()
This gives a txt file like below only after it has truncated the file. The origanal file created is fine, and called back when the form loads (This file is created when the form is closed)
20:30 18/03/2006
12:34 18/03/2006
12:45 19/03/2006
Many thanks in advance Hassan