Save file from a byte[] in C# NET 3.5

后端 未结 5 1699
长发绾君心
长发绾君心 2021-02-04 04:39

My TCP Client receives a image within a packet.The image is compressed with zlib.The task is to decompress the image and put it on the form.

I\'m planning to save the co

5条回答
  •  一生所求
    2021-02-04 05:14

    You can try this code

     private void t1()
        {
            FileStream f1 = new FileStream("C:\\myfile1.txt", FileMode.Open);
            int length = Convert.ToInt16(f1.Length);
            Byte[] b1 = new Byte[length];
            f1.Read(b1, 0, length);
            File.WriteAllBytes("C:\\myfile.txt",b1);
            f1.Dispose();
        }
    

提交回复
热议问题