View Single Post
Old 04-08-2014, 03:45 PM
haider haider is offline
Join Date: Apr 2014
Posts: 24
Unhappy reading binary files in array

hi every one
i want to make a program in visual baisc 2010 to read any file time
avi mp3 mp4 mkv jpg zip rar txt pdf exe dll and put its binary data in an array
or storage it in RAM

i tried to write a code and use filesteam but i fail

HTML Code:
Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim myCoolFile As String = "C:\AMD\1.txt"

        Dim myFileStream As System.IO.FileStream
        myFileStream = New System.IO.FileStream(myCoolFile, _
                 IO.FileMode.OpenOrCreate, IO.FileAccess.Read, IO.FileShare.ReadWrite)

        Dim x As Integer = myFileStream.Length - 1
        Dim myArray(x) As Byte
        Dim i As Integer = 0
        For Each mybyte As Byte In myFileStream
            myArray(i) = mybyte
            i += 1 '

        TextBox1.Text = x

    End Sub
End Class
Reply With Quote