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
- Author: Kris Bulté
- Submitted on: 8/8/2012 1:22:22 PM
- Language: C#
- Type: System.String
- Views: 3259
Double click on the code to select all.