日期:2014-05-18 浏览次数:21001 次
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);
}
}
}