من چطوري ميتونم محتويات يك فايل باينري رو بخونم
Printable View
من چطوري ميتونم محتويات يك فايل باينري رو بخونم
می تونی از همون 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());
}
}