473,385 Members | 1,720 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.

binary writer only writes one file

hi, this code only wrtie one of the files its supposed to and i cant figure
out y....any help would be awsome
Private Sub btnnext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnnext.Click

Dim Open As New FolderBrowserDialog

strName = InputBox("Enter Program Name", "Enter Name", "NewSetup")

Me.btnnext.Enabled = False

With Open

.RootFolder = 0
.ShowNewFolderButton = True

If .ShowDialog = Windows.Forms.DialogResult.OK And .SelectedPath
<> Nothing Then

Path = .SelectedPath

End If

End With

For Each str As String In arrFiles

Dim fs As New FileStream(str, FileMode.Open, FileAccess.Read)

Me.tsprogInfo.ProgressBar.Maximum += CInt(fs.Length)

fs.Close()

Next

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 for using CreateInstaller!")

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

End Sub
--
-iwdu15
Apr 1 '06 #1
0 1118

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...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
8
by: Yeow | last post by:
hello, i was trying to use the fread function on SunOS and ran into some trouble. i made a simple test as follows: i'm trying to read in a binary file (generated from a fortran code) that...
8
by: Roberto Rocco | last post by:
Hello, I have a struct and want to stream it to a file (binary). I cannot use because this is not supported under the Compact Framework. What is the best approach to use? Another question in...
3
by: Joshua Russell | last post by:
Hi, I've got a program (see source below) that makes a file and fills it with random binary values (from 0 to 255). The source below works, however the program creates files at a rate of about...
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...
1
by: Ryan Ternier | last post by:
I'm writing a file out using StreamWriter. What i'm outputting is a 6,398 lines of stupid Jscript arrays. Yes the system needs to be very very dynamic, and they don't want a page reload. 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;...
15
by: Jacques | last post by:
Hi I am an dotNet newby, so pardon my ignorance. I am looking for a method of saving/copying a managed class to a stream/file WITHOUT saving the object's state, eg. if I have a ref class with...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.