当前位置:Gxl网 > 互联网 > 上传转字节再转图片

上传转字节再转图片

时间:2021-07-01 10:21:17 帮助过:2人阅读

winform版

 

DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
string path = openFileDialog1.FileName;
FileStream file = new FileStream(path, FileMode.Open);
int sum=(int)file.Length;
byte[] bytes = new byte[sum];
file.Read(bytes,0,sum);
FileStream files = File.Create(@"D:\1.jpg");
files.Write(bytes, 0, sum);
}
else
{
MessageBox.Show("请选择文件", "");
}