C# winform 程序,在用SaveFileDialog选择完路径后,主界面如何置顶?
3个回答
展开全部
SaveFileDialog实际是个模态窗体,所以主界面无法置顶;
如果你非要达到这样的效果,自己做一个类似SaveFileDialog的窗体。
如果你非要达到这样的效果,自己做一个类似SaveFileDialog的窗体。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2010-11-19
展开全部
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();
}
}
你试一下
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();
}
}
你试一下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询