473,385 Members | 1,282 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

BinaryWriter Write adds Carrots

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

Nov 21 '05 #1
5 1491
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

"Travis Llewellyn" <travisll"@" wrote:
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

Nov 21 '05 #2
Kerry,

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

Travis

"=?Utf-8?B?S2VycnkgTW9vcm1hbg==?="
<Ke**********@discussions.microsoft.com> wrote in
news:38**********************************@microsof t.com:
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

"Travis Llewellyn" <travisll"@" wrote:
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


Nov 21 '05 #3
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 Llewellyn" <travisll"@" wrote:
Kerry,

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

Travis

"=?Utf-8?B?S2VycnkgTW9vcm1hbg==?="
<Ke**********@discussions.microsoft.com> wrote in
news:38**********************************@microsof t.com:
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

"Travis Llewellyn" <travisll"@" wrote:
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


Nov 21 '05 #4
Travis,
Have you tried writing the individual characters instead of writing the
entire string?
For s = 0 To shrdvars.al.Count - 1
hello = three.parsrecord(shrdvars.al(s)) rw.Write(hello.ToCharArray()) Next

Hope this helps
Jay

"Travis Llewellyn" <travisll"@"comfedcu.org> wrote in message
news:Xn*********************************@207.46.24 8.16... Kerry,

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

Travis

"=?Utf-8?B?S2VycnkgTW9vcm1hbg==?="
<Ke**********@discussions.microsoft.com> wrote in
news:38**********************************@microsof t.com:
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

"Travis Llewellyn" <travisll"@" wrote:
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

Nov 21 '05 #5
Jay,

This worked great.
Thanks
Travis

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in
news:e9**************@tk2msftngp13.phx.gbl:
Travis,
Have you tried writing the individual characters instead of writing
the entire string?
For s = 0 To shrdvars.al.Count - 1
hello = three.parsrecord(shrdvars.al(s)) rw.Write(hello.ToCharArray()) Next


Hope this helps
Jay

"Travis Llewellyn" <travisll"@"comfedcu.org> wrote in message
news:Xn*********************************@207.46.24 8.16...
Kerry,

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

Travis

"=?Utf-8?B?S2VycnkgTW9vcm1hbg==?="
<Ke**********@discussions.microsoft.com> wrote in
news:38**********************************@microsof t.com:
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

"Travis Llewellyn" <travisll"@" wrote:

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



Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mark Miller | last post by:
I have a char array and when I write it to a file using BinaryWriter the position of the pointer is the size of the array + 1. For example: writing char leaves the pointer at position 26 after...
6
by: ThunderMusic | last post by:
Hi, In my app, I open a file using a FileStream then pass it to a BinaryWriter. I then use the BinaryWriter instance to write to my file. But a problem arose : The file never gets bigger than 1kb....
3
by: Peyman | last post by:
Hello all, This is my first c# program. And I seem to have a problem. Here is the code: FileStream myStream = new FileStream("d:\\test.txt", FileMode.Create, FileAccess.Write); BinaryWriter...
17
by: Filip Strugar | last post by:
Considering that the BinaryWriter/BinaryReader object closes the underlaying stream upon being gc collected, is the following code correct, and if it is what is the reason preventing BinaryWriter...
3
by: Eugene | last post by:
I'm trying to write a class which uses BinaryWriter as its base but allows for queuing of write requests Public Class QueuedBinaryWriter Inherits BinaryWriter I override all the Write methods...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.