如何在Wpf C#中使用Dialogbox将文件保存在另一个路径中 [英] How Do I Save The File In Another Path Using Dialogbox In Wpf C#
本文介绍了如何在Wpf C#中使用Dialogbox将文件保存在另一个路径中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
OpenFileDialog dlg = new OpenFileDialog();
dlg.DefaultExt = "png";
dlg.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files(*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";
if (dlg.ShowDialog().Value)
{
// Open document
string filename = dlg.FileName;
//dlg1.Save();
txtIdProofLocation.Text = filename;
}
i已保存按钮,当我单击保存按钮时,所选图像将存储到指定位置
i have save button , when i click the save button selected image will store into the specified location
推荐答案
据我所知,您要选择一个文件然后
将其保存到其他位置。
选择保存文件名
可以通过实现SaveFileDialog 。
我调整了你的代码:
As far as I understood, you want to select a file and then
save it to another location.
Selecting a file name for saving
can be achieved by using the SaveFileDialog.
I adapted your code:
OpenFileDialog ofd = new OpenFileDialog();
SaveFileDialog sfd = new SaveFileDialog();
ofd.DefaultExt = "png";
ofd.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files(*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";
if (ofd.ShowDialog().Value)
{
if(sfd.ShowDialog().Value)
{
File.Copy(ofd.FileName, sfd.FileName);
}
}
使用保存文件对话框 [ ^ ]获取所选路径名,并根据需要编写文件。
Use a SaveFileDialog[^] to get the selected pathname, and write your file as required.
这篇关于如何在Wpf C#中使用Dialogbox将文件保存在另一个路径中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文