openFileDialog1.ShowDialog();
if (openFileDialog1.ShowDialog()==DialogResult.OK)
{
openFileDialog1.OpenFile();
}
但是程序没反应。~
if (openFileDialog1.ShowDialog()==DialogResult.OK)
{
openFileDialog1.OpenFile();
}
但是程序没反应。~
请大哥们贴代码:~
我看过MSDN了,但是if((myStream = openFileDialog1.OpenFile())!= null)
{
// Insert code to read the stream here.
myStream.Close();
}
好像是白说
压根就没会说,只是说插入代码,我也知道呀~我就是不会写。~晕~
那么我点他的话就打开QQ呀
http://blog.csdn.net/mngzilin/archive/2010/01/01/5118256.aspx
OpenFile()只打开数据文件,而且是只读的,你那个QQ。Exe是可执行文件,那应该打开个进程吧!
无语了~~~~~~~~~
你是想在程序中运行另一个程序文件,应该用Process类
但是OpenFiledialog的目的是打开一个窗体,让用户选择文件,这是他的主要用法你想要的东西和你描述的问题根本不沾边,难怪楼上的人都搞不懂
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string name = openFileDialog1.FileName;
//先获取到文件名,再用其他方法打开文件,或者用导入stream在textbox中显示。如果是exe文件用Process打开
}
p.StartInfo.FileName = @"c:\program files\tencent\qq.exee";
p.StartInfo.WorkingDirectory = @"c:\program files\tencent";
p.Start();
是惯性思维影响了我~
阁下的意思是:应该这样写?
if (openFileDialog1.ShowDialog()==DialogResult.OK)
{
Process p = new Process();
p.StartInfo.FileName = openFileDialog1.FileName;
// p.StartInfo.WorkingDirectory = @"c:\program files\tencent";
p.Start();
}
if (openFileDialog1.ShowDialog()==DialogResult.OK)
这两句重复了,用一句就可以。
openFileDialog1.ShowDialog(this)==DialogResult.OK)
结贴了~