By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

binary writer only writes one file

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.