//
将 byte[] 转成Stream
public static Stream ConvertToStream( byte[] bytes)
{
Stream result;
try
{
Stream stream = new MemoryStream(bytes);
result = stream;
}
catch (Exception ex)
{
throw ex;
}
return result;
}
//将完整物理路径转成Stream
public static Stream ConvertToStream(string fileName)
{
Stream result;
try
{
FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
byte[] array = new byte[fileStream.Length];
fileStream.Read(array, 0, array.Length);
fileStream.Close();
Stream stream = new MemoryStream(array);
result = stream;
}
catch (Exception ex)
{
throw ex;
}
return result;
}