Answers for "c# load a file into binary buffer"

C#
0

c# load a file into binary buffer

public byte[] FileToByteArray(string fileName)
{
    byte[] buff = null;
    FileStream fs = new FileStream(fileName, 
                                   FileMode.Open, 
                                   FileAccess.Read);
    BinaryReader br = new BinaryReader(fs);
    long numBytes = new FileInfo(fileName).Length;
    buff = br.ReadBytes((int) numBytes);
    return buff;
}
Posted by: Guest on March-28-2022

C# Answers by Framework

Browse Popular Code Answers by Language