Foro de elhacker.net

Programación => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: TrashAmbishion en 26 Octubre 2013, 18:08 pm



Título: Duda abriendo archivo en binario para lectura !!
Publicado por: TrashAmbishion en 26 Octubre 2013, 18:08 pm
Código
  1.  
  2.        Dim MyAddress As Integer = &H290968
  3.        Dim a As Object
  4.  
  5.        Dim fs As FileStream = New FileStream(fileName, FileMode.Open)
  6.  
  7.        Dim br As BinaryReader = New BinaryReader(fs)
  8.  
  9.        Dim sz As Integer = fs.Length ' you don't neccessarily need this, I use this in my app. toset the size an Array.
  10.  
  11.        br.BaseStream.Seek(MyAddress, SeekOrigin.Begin) 'moves to the address you want
  12.  
  13.        a = br.ReadInt32() 'reads Both Bytes (characters you want)
  14.  
  15.        ListBox1.Items.Add("My Address Data: " + (a).ToString()) 'Adds the data to a listbox
  16.  
  17.        br.Close() 'close the Binary Reader
  18.  
  19.        fs.Close() ' close the FileStream
  20.  
  21.  

Esto es un ejemplo que me encontre por la Internet, quisiera saber donde pongo la cantidad de bytes que quiero leer, gracias

Porque me pone 1702129257 y no son los datos que necesito en el editor Hexadecimal me da otros datos...

Gracias de antemano


Título: Re: Duda abriendo archivo en binario para lectura !!
Publicado por: Eleкtro en 26 Octubre 2013, 21:24 pm
A mi me lee corréctamente los bytes

Aquí puedes especificar la cantidad de bytes a leer:

Citar
Código:
a = br.ReadInt32()

Código
  1. a = br.ReadBytes(2)
  2. MsgBox(BitConverter.ToInt32(a, 0))

Saludos