zoukankan      html  css  js  c++  java
  • OpenFileDialog

     string resultFile = "";


                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                openFileDialog1.InitialDirectory = "D://Patch";
                openFileDialog1.Filter = "All files (*.*)|*.*|txt files (*.txt)|*.txt";
                openFileDialog1.FilterIndex = 2;
                openFileDialog1.RestoreDirectory = true;
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                    resultFile = openFileDialog1.FileName; 

    resultFile 就能得到你选中文件的路径

    OpenFileDialog控件有以下基本属性

    InitialDirectory 对话框的初始目录
    Filter 要在对话框中显示的文件筛选器,例如,"文本文件(*.txt)|*.txt|所有文件(*.*)||*.*"
    FilterIndex 在对话框中选择的文件筛选器的索引,如果选第一项就设为1
    RestoreDirectory 控制对话框在关闭之前是否恢复当前目录
    FileName 第一个在对话框中显示的文件或最后一个选取的文件
    Title 将显示在对话框标题栏中的字符
    AddExtension 是否自动添加默认扩展名
    CheckPathExists
    在对话框返回之前,检查指定路径是否存在
    DefaultExt 默认扩展名
    DereferenceLinks 在从对话框返回前是否取消引用快捷方式
    ShowHelp
    启用"帮助"按钮
    ValiDateNames 控制对话框检查文件名中是否不含有无效的字符或序列
  • 相关阅读:
    zoj 3135 Party of 8g 最大点权独立集
    hdu 5352 MZL's City 最小费用最大流
    hdu 5351 MZL's Border 打表+高精度
    poj 3155 Hard Life 最大密度子图
    希尔排序的温习
    折半查找法的温习
    几所可能去的院校之对比与抉择
    重温排序算法
    5-17 汉诺塔的非递归实现 (25分)
    c语言从文件中读取数据作为输入
  • 原文地址:https://www.cnblogs.com/zhangdw/p/2574764.html
Copyright © 2011-2022 走看看