Beispiel #1
0
        /// <summary>
        /// Reads n bytes from the file into an unmanaged buffer. Remember to dispose the buffer when you are finished with it.
        /// </summary>
        public static UnmanagedBuffer ReadUnmanaged(this SafeFileHandle hFile, int size)
        {
            var r = new UnmanagedBuffer(size);

            hFile.Read(r);
            return(r);
        }
Beispiel #2
0
        /// <summary>
        /// Read data from the file into a byte array.
        /// </summary>
        public static byte[] Read(this SafeFileHandle hFile, int size)
        {
            var r = new byte[size];

            using (var pin = r.Pin())
                hFile.Read(pin);
            return(r);
        }