BinaryWriter Write adds Carrots

  • Thread starter Thread starter Travis Llewellyn
  • Start date Start date
T

Travis Llewellyn

I am writing a program that write out and array that I have stored. It
writes out the whole array but adds a Carrot "^" in front of each
section it writes.

If I do a debug.writeline(hello) it shows the line perfect in the
immediate windows without the carrot.

Any help would be appreciated.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
shrdvars.wflname = Microsoft.VisualBasic.Mid(ofdlg1.FileName,
21, 12)
sfdlg1.FileName = shrdvars.wflname
sfdlg1.InitialDirectory() = "h:\dp\testfolder\out\"
sfdlg1.ShowDialog()
Dim fsw As New FileStream(sfdlg1.FileName, FileMode.CreateNew)
Dim rw As New BinaryWriter(fsw)
'FileOpen(1, sfdlg1.FileName, OpenMode.Binary, OpenAccess.Write,
OpenShare.Default, 94)
Dim three As New shrdvars
Dim hello As String
Dim s As Integer
For s = 0 To shrdvars.al.Count - 1
hello = three.parsrecord(shrdvars.al(s))
rw.Write(hello)
Next
rw.Close()
fsw.Close()


End Sub
 
Travis,

From the .Net online documentation about BinaryWriter's Write (string) method:

"A length-prefixed string represents the string length by prefixing to the
string a single byte or word that contains the length of that string."

Kerry Moorman
 
Kerry,

Thanks for the quick reply, Can you give me a quick way to drop that
byte before writing?

Travis
 
Travis,

The binarywriter has to add that length byte so the binaryreader can
correctly read the file.

Perhaps you need to use some other output technique, instead of binary.

Kerry Moorman
 
Travis,
Have you tried writing the individual characters instead of writing the
entire string?

Hope this helps
Jay
 
Jay,

This worked great.
Thanks
Travis

Travis,
Have you tried writing the individual characters instead of writing
the entire string?


Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top