473,387 Members | 1,489 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,387 software developers and data experts.

weirdly acting binary writer

hi...im creating my own installation program using a binary reader and
filestreams. the problem is trying to get each file into a single file. for
reasons i cant figure out, it only write the first file i select to the main
file, even if the array contains more than 1 file....i cant seem to figure it
out so if anyone has any help, thatd b great
Try

Dim fsOutput As New FileStream(Path & "\" & strName & ".fif",
FileMode.Append, FileAccess.Write)
Dim sw As New StreamWriter(fsOutput)

Dim fsEULA As New FileStream(Path & "\Config.dat",
FileMode.Create, FileAccess.Write)
Dim swEULA As New StreamWriter(fsEULA)

Dim fs As FileStream

Dim fsOut As FileStream
Dim bw As BinaryWriter

Dim count As Integer = 0

Dim ReadBytes As Byte()

Dim numBytes As Integer = 0

For count = 0 To arrFiles.Length - 1

fs = New FileStream(arrFiles(count), FileMode.Open,
FileAccess.Read)

fsOut = New FileStream(Path & "\DataFile.dat",
FileMode.Append, FileAccess.Write)
bw = New BinaryWriter(fsOut)

Me.tsLblinfo.Text = "Adding File " &
arrFiles(count).Substring(arrFiles(count).LastInde xOf("\") + 1) & " to
installer"

ReDim ReadBytes(fs.Length)
fs.Read(ReadBytes, 0, fs.Length)

Application.DoEvents()

For Each bt As Byte In ReadBytes

bw.Write(bt)

If Me.tsprogInfo.ProgressBar.Value + 1 <=
Me.tsprogInfo.ProgressBar.Maximum Then

Me.tsprogInfo.ProgressBar.Value += 1

ElseIf Me.tsprogInfo.ProgressBar.Value + 1 >
Me.tsprogInfo.ProgressBar.Maximum Then

Me.tsprogInfo.ProgressBar.Value =
Me.tsprogInfo.ProgressBar.Maximum

Else

Me.tsprogInfo.ProgressBar.Value = 0

End If

Next

sw.WriteLine(arrFiles(count) & "|" & fs.Length)

fs.Close()

Array.Clear(ReadBytes, 0, ReadBytes.Length)

fsOut.Flush()
bw.Flush()
bw.Close()
fsOut.Close()

Next

swEULA.WriteLine(Info.strEULA)

fsEULA.Flush()
swEULA.Flush()
swEULA.Close()
fsEULA.Close()

fsOutput.Flush()
sw.Flush()
sw.Close()
fsOutput.Close()

MsgBox("Installer Created! Thank You!")

Catch ex As Exception

My.Computer.Audio.PlaySystemSound(Media.SystemSoun ds.Exclamation)
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)

Finally

Me.btnnext.Enabled = True

End Try

--
-iwdu15
Mar 7 '06 #1
0 658

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

Similar topics

2
by: J. Campbell | last post by:
I have an object with a member function that I'm using to generate a stream of binary data that, rather than using, I want to output directly to a file. It has a member function that returns an...
2
by: S.Creek | last post by:
Hi, I need to take few files (images in my case) and create one file out of them, this file should be accessed so i can grab a single image from it if necessary, i thought of taking all the...
2
by: Edvin | last post by:
Why is binary array written to a file different than when converting the binary array to string and then writing it to file! For example: // --- Allocate byte array byte arrByte = new byte;...
3
by: DBC User | last post by:
I have a binary writer and when I write a unsigned int I was expecting it to write 4 bytes but it is writing 5 bytes and last last byte being 0B. Also when I write string it is adding byte 01 at...
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: 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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.