//把流转化为文件
 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);
    }

求补充。。。。。。。。。。。。。。

相关文章:

  • 2023-02-21
  • 2022-02-14
  • 2022-01-02
  • 2021-05-29
  • 2022-12-23
  • 2021-12-22
  • 2021-12-20
  • 2021-05-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2021-07-13
  • 2021-10-12
  • 2021-05-27
相关资源
相似解决方案