使用此类可检查某个文件是否存在并打开该文件。
ShowReadOnly 属性确定是否在对话框中显示只读复选框。
ReadOnlyChecked 属性指示是否选中只读复选框。
此类的大多数功能都可以在 FileDialog 类中找到。
如果要使用户能够选择文件夹而不是文件,
请改用 FolderBrowserDialog。
实例:
private void button1_Click(object sender, System.EventArgs e)
{
Stream myStream;
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)
{
if((myStream = openFileDialog1.OpenFile())!= null)
{
// Insert code to read the stream here.
myStream.Close();
}
}
}
本文名称:OpenFileDialog方法的编辑
标题网址:https://www.cdcxhl.com/article46/jgpieg.html
成都网站建设公司_创新互联,为您提供服务器托管、网站设计公司、定制开发、电子商务、手机网站建设、软件开发
广告
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源:
创新互联