C# winform 程序,在用SaveFileDialog选择完路径后,主界面如何置顶?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C# winform 程序,在用SaveFileDialog选择完路径后,主界面如何置顶?相关的知识,希望对你有一定的参考价值。

没法置顶,
选完路径点了确定之后SaveFileDialog关闭,点确定的事件中你可以把路径记录在其他地方不一定非得确定就保存.
参考技术A SaveFileDialog实际是个模态窗体,所以主界面无法置顶;
如果你非要达到这样的效果,自己做一个类似SaveFileDialog的窗体。
参考技术B StreamWriter writer;
StreamReader reader;
FileStream fs;
private void openBtn_Click(object sender, System.EventArgs e)

string theFile;
openFileDialog1.InitialDirectory=Application.ExecutablePath;
openFileDialog1.Filter="word Files(*.doc)|*.doc|All Files(*.*)|*.*";
if (openFileDialog1.ShowDialog()==DialogResult.OK )

theFile=openFileDialog1.FileName;
try

fs=new FileStream(theFile,FileMode.Open);
reader=new StreamReader(fs);
textBox1.Text=reader.ReadToEnd();

catch(Exception excep)

MessageBox.Show(excep.Message);

finally

reader.Close();
fs.Close();




private void saveBtn_Click(object sender, System.EventArgs e)

string theFile;
saveFileDialog1.InitialDirectory=Application.ExecutablePath;
saveFileDialog1.Filter="word Files(*.doc)|*.doc|All Files(*.*)|*.*";
saveFileDialog1.OverwritePrompt=true;
saveFileDialog1.ShowDialog();
theFile=saveFileDialog1.FileName;
try

fs=new FileStream(theFile,FileMode.Create);
writer=new StreamWriter(fs);
writer.Write(textBox1.Text);

catch (Exception excep)

MessageBox.Show(excep.Message);

finally

writer.Flush();
writer.Close();
fs.Close();


你试一下

以上是关于C# winform 程序,在用SaveFileDialog选择完路径后,主界面如何置顶?的主要内容,如果未能解决你的问题,请参考以下文章