i need to pick up an excel file form my asp.net mvc project folder and encode it in base64 string.
mine code right now:
string base64 = String.Empty;
var pathName = Server.MapPath("~/App_Data/ImportTemplate.xlsx");`
byte[] docBytes = null;
using (StreamReader strm = new StreamReader(pathName, System.Text.Encoding.UTF8))
{
Stream s = strm.BaseStream;
BinaryReader r = new BinaryReader(s);
docBytes = r.ReadBytes(Convert.ToInt32(r.BaseStream.Length));
base64 = Convert.ToBase64String(docBytes);
r.Close();
s.Close();
strm.Close();
}
so far this doesn't work properly. Any suggestions?