本文介绍了Winforms另存为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有人知道任何文章或网站显示如何在获胜表格中创建另存为"对话框.我有一个按钮,用户单击并序列化一些数据,然后该用户使用此另存为"框指定要保存数据的位置.
Does anyone know any articles or sites showing how to create a "Save as" dialogue box in win forms. I have a button, user clicks and serializes some data, the user than specifies where they want it saved using this Save as box.
推荐答案
您的意思是?
You mean like SaveFileDialog
?
从MSDN示例中进行了一些修改:
From the MSDN sample, slightly amended:
using (SaveFileDialog dialog = new SaveFileDialog())
{
dialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
dialog.FilterIndex = 2 ;
dialog.RestoreDirectory = true ;
if (dialog.ShowDialog() == DialogResult.OK)
{
// Can use dialog.FileName
using (Stream stream = dialog.OpenFile())
{
// Save data
}
}
}
这篇关于Winforms另存为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!