我有一个名为 image1 的图像控件 (WPF),当我单击命令按钮时它会加载图像(这是有关该事件的代码)。现在,如果我想将该图像文件复制到当前目录(即项目目录)上,我必须做什么?
private void commandButton1_Click(object sender, System.Windows.RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.DefaultExt = "*.jpg";
dlg.Filter = "Image Files|*.jpg";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
image1.Source = new BitmapImage(new Uri(dlg.FileName));
}
// to do
}
}