public static string ToBase64(this FileInfo fi)
{
FileStream fs = fi.OpenRead();
byte[] filebytes = new byte[fs.Length];
fs.Read(filebytes, 0, Convert.ToInt32(fs.Length));
string encodedData = Convert.ToBase64String(filebytes, Base64FormattingOptions.InsertLineBreaks);
fs.Close();
return encodedData;
}
}