我正试图编写“打开对话框”,要求:只打开文件图片()
private void 打开图片文件ToolStripMenuItem1_Click(object sender, EventArgs e)
{
OpenFileDialog dlgOpen = new OpenFileDialog();
dlgOpen.Filter = "位图文件(*.bmp)|GIF(*.gif)|PNG(*.png)|JPEG(*.jpeg;*jpe;*.jpg;*.jifi)|所有图片文件"; //??执行到这一步时就会出错!
dlgOpen.ShowDialog();
}
解决方案 »
- 求救 如何获取Memcached中的所有KEY
- 关于枚举
- 小弟不才,想问一个问题,实在是对基础知识掌握的不扎实
- winform :webBrowser.Navigate(@"c:\a.htm"); HtmlDocument htmlDoc = myBrowser.Document;htmlDoc.Body.//得到的值怎么为空呢
- vs2005
- 怎么控制他的输出字符串的长度<asp:lable id="lable1" runat="server" text='<%# Eval("mm1")%>'></lable>
- 非常简单而又奇怪的一个问题,请大家指教。。
- 如何实现遨游浏览器的那种后台打开新窗体功能?
- 关于用。net开发插件的问题
- 如果DataGrid允许排序,那怎么取DataGrid的索引值啊,进而取一条记录?
- 能不能举个例子往winform中的datagriedview中添加数据啊
- web.config中的<identity>标签的问题,急!!!大家帮忙看看!!!
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);
}
}
}