MemoryStream ms=new MemoryStream(); using (FileStream fs = new FileStream("C:\\1.jpg", FileMode.Create)) { BinaryWriter bw = new BinaryWriter(fs); bw.Write(ms.ToArray()); bw.Close(); fs.Flush(); }