问题描述
您好,
我正在尝试提供一个提示窗口,供您使用按钮进一步选择文件. 这里是corr.按钮单击的事件.现在,在我单击corr之后.按钮,会话将结束.
Hi,
I'm trying to have a prompt window for further choosing a file using a button. Here is the corr. button-clicked event. Now after I've clicked the corr. button to go further, the session will just end. private void bt_browse_Clicked(object sender, EventArgs e)
{
Stream myStream = 空 ;
Stream myStream = null;
OpenFileDialog openFileDialog1 = 新 OpenFileDialog ();
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = " c:\\" ;
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = " JPG文件(* .jpg)| * .jpg |全部文件(*.*)| *.*" ;
openFileDialog1.Filter = "JPG files (*.jpg)|*.jpg|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 2;
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true ;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog ()== DialogResult .确定)
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
尝试
try
{
if (((myStream = openFileDialog1.OpenFile())!= null )
if ((myStream = openFileDialog1.OpenFile()) != null)
{
使用 (myStream)
using (myStream)
{
tb_photo_fl.Text = openFileDialog1.FileName;
tb_photo_fl.Text = openFileDialog1.FileName;
}
}
}
捕获 ( 例外 例如)
catch (Exception ex)
{
MessageBox .Show( "错误:无法从磁盘读取文件.原始错误:" +例如消息);
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
}
有人知道这个问题的原因吗? (我使用的是2008 Express版本)
Does anyone know the reason of this issue? (I'm using version 2008 Express)
推荐答案
这篇关于具有“浏览"窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!