openFileDialog 打开应用程序
private void button4_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
openFileDialog1.OpenFile();
}
是这样写吗,但是选择一个.exe .doc .xls文件就是没有反应
[解决办法]
当然没反映了,你打开后要干嘛都没写啊.
[解决办法]
Process.Start(openFileDialog1.Filename);
[解决办法]
OpenFileDialog open = new OpenFileDialog(); if (open.ShowDialog() == DialogResult.OK) { System.Diagnostics.Process.Start(open.FileName); }
[解决办法]
設置所要打開的文件格式..openFileDialog1 屬性里有
[解决办法]
发重了.
[解决办法]
如果openFileDialog1.ShowDialog() 的返回值是DialogResult.OK
那你可以用openFileDialog1.Filename做你想做的事情啊!
[解决办法]
private void button4_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
/////你自己想做的事
}
}
[解决办法]
private void button1_Click(object sender, System.EventArgs e){ Stream myStream = null; OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\" ; openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; openFileDialog1.FilterIndex = 2 ; openFileDialog1.RestoreDirectory = true ; if(openFileDialog1.ShowDialog() == DialogResult.OK) { try { if ((myStream = openFileDialog1.OpenFile()) != null) { using (myStream) { // Insert code to read the stream here. } } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } }}