PDA

View Full Version : خواندن فايل باینری



help man
یک شنبه 28 مهر 1387, 03:52 صبح
من چطوري ميتونم محتويات يك فايل باينري رو بخونم

SMRAH1
یک شنبه 28 مهر 1387, 08:03 صبح
می تونی از همون FileStream استفاده کنی.
مثال MSDN اش اینطوریه (نام فایل رو هرطور می خوای بده فرقی هم توی Text یا Binary نیست):

using System;
using System.IO;

class FSRead
{
public static void Main()
{
//Create a file stream from an existing file.
FileInfo fi=new FileInfo("c:\\csc.txt");
FileStream fs=fi.OpenRead();

//Read 100 bytes into an array from the specified file.
int nBytes=100;
byte[] ByteArray=new byte[nBytes];
int nBytesRead=fs.Read(ByteArray, 0, nBytes);
Console.WriteLine("{0} bytes have been read from the specified file.", nBytesRead.ToString());
}
}