Advertisement

图片与Byte之间、文件与字节流之间的转换方法

阅读量:

///


/// 将文件内容转换为byte[]数组
///

///
///
private byte[] FileContent(string fileName)
{
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
try
{
byte[] buffur = new byte[fs.Length];
fs.Read(buffur, 0, (int)fs.Length);
return buffur;
}
catch (Exception ex)
{
//ex.Message
return null;
}
finally
{
if (fs != null)
{
fs.Close();
}
}
}

///


/// C#中实现文件与字节流之间的转换方式
///

///
/// </p

全部评论 (0)

还没有任何评论哟~