RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
OpenFileDialog方法的编辑
 
 
使用此类可检查某个文件是否存在并打开该文件。
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方法的编辑
地址分享:http://sczitong.cn/article/jgpieg.html