首页 > 代码库 > 上传转字节再转图片

上传转字节再转图片

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("请选择文件", "");
}

上传转字节再转图片