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("请选择文件", "");
}
时间: 2024-11-15 10:42:12