//把流轉化為文件
public static void StreamToFile(Stream stream, string filepath) { byte[] bytes = StreamToBytes(stream); FileStream fileStream = new FileStream(filepath, FileMode.Create); fileStream.Write(bytes, 0, bytes.Length); fileStream.Flush(); fileStream.Close(); }
//把流轉化為字節數組 public static byte[] StreamToBytes(Stream stream) { MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); }
//把流轉化為Base64字符串
public static string StreamToString(Stream stream) { byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); string base64string = Convert.ToBase64String(buffer); return base64string; }
//把Base64字符串轉化為流
pubblic static Stream StringToStream(string str)
{
byte[] bt = Convert.FromBase64String(str);
System.IO.MemoryStream stream = new System.IO.MemoryStream(bt);
}
求補充。。。。。。。。。。。。。。