davesil2 Posted September 2, 2004 Posted September 2, 2004 I'm trying to pass sections of the byte array at a time with error checking. Right now I have code that I thought would work but appearantly does not. Basically I'm trying to read a file into the stream reader then pick a section of byte to grab from it to pass to something else. I'm basically using something close the the following pseudo code. dim fs as filestream = new filestream("C:\autoexec.bat", FileMode.open) dim ByteFileSection() as byte = new byte(50) {} (I'm not sure what the curly brackets do) fs.read(bytefilesection, startByte, length) I basically do this in a loop and the startbyte increases by 50 every time arround. Perhaps someone has an example or something that I might be able to use. -David Silberhorn Quote
Joe Mamma Posted September 2, 2004 Posted September 2, 2004 something like this? Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim fs As New FileStream("c:\dummy.txt", FileMode.Open) Dim tr As New BinaryReader(fs) While tr.BaseStream.Position < tr.BaseStream.Length Dim bytes(50) As Byte bytes = tr.ReadBytes(bytes.Length) ProcessBytes(bytes) End While End Sub Private Sub ProcessBytes(ByVal bytes() As Byte) Dim ascii As New ASCIIEncoding Dim decoded As String = ascii.GetString(bytes) TextBox1.AppendText(decoded) End Sub Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.