温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

OpenFileDialog 方法的编辑

发布时间:2020-07-15 07:14:27 来源:网络 阅读:286 作者:zhangaihongde 栏目:编程语言
 
 
使用此类可检查某个文件是否存在并打开该文件。
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();
        }
    }
}
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI