ToBytes

public static byte[] ToBytes(this string fileName)
{
   if(!File.Exists(fileName))
     throw new FileNotFoundException(fileName);

   return File.ReadAllBytes(fileName);
}
Example:
var bytes = @"C:\Temp\Products.pdf".ToBytes();

Description

Converts a file on a given path to a byte array.

Details

Double click on the code to select all.

 

;