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 13:22:22
- Language: C#
- Type: System.String
- Views: 3790
Double click on the code to select all.