public static byte[] FileToBytes(string filePath)
{
byte[] data = null;
try
{
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
long numBytes = new FileInfo(filePath).Length;
//logger.LogInfo("Library.Functions.FileToBase64(): Path:" + filePath + " Bytes:" + numBytes);
data = br.ReadBytes((int)numBytes);
}
catch (Exception ex)
{
logger.LogInfo("Library.Functions.FileToBase64(): Exception: " + ex.ToString());
return null;
}
return data;
}
{
byte[] data = null;
try
{
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
long numBytes = new FileInfo(filePath).Length;
//logger.LogInfo("Library.Functions.FileToBase64(): Path:" + filePath + " Bytes:" + numBytes);
data = br.ReadBytes((int)numBytes);
}
catch (Exception ex)
{
logger.LogInfo("Library.Functions.FileToBase64(): Exception: " + ex.ToString());
return null;
}
return data;
}
No comments:
Post a Comment