Writing to a Text File

rmatthew

Well-known member
Joined
Dec 30, 2002
Messages
115
Location
Texas
I need to dump a Queue to a textfile with one item on each line. I am using the following code:

Dim objStreamWriter As System.IO.StreamWriter
readthread.Abort()
objStreamWriter = New System.IO.StreamWriter("c:\testtext.txt")
Do While MessageQue.Count > 0
objStreamWriter.WriteLine(MessageQue.Dequeue)
Loop
objStreamWriter.Close()

however; seems it just writes one line to the file (and I know I have more than that in the Queue?????
 
That code looks fine to me, step through it with a debugger and you may find that the WriteLine is only being called once.
 
Seems like it should work assuming MessageQue is a Queue object. Did you type your sample by hand, as I think Dequeue needs parens since its a method not a property... but try as divil said, walk through code - or write out the Count before you get in the loop to see if its > 1.

-nerseus
 
Sadly VB.NET doesnt enforce parens when calling a function with no parameters.
 
Back
Top