就是这么一个,简单的选择文件,应该这么弄?下载的那个也顺便说一下是怎么弄的吧

解决方案 »

  1.   

    这不就是一个文件选择的功能吗,这还是C#的东西嘛,使用一个Microsoft.Win32.FileOpenDialog不就解决了?
      

  2.   

            void button1_Click(object sender, RoutedEventArgs e)
            {
                OpenFileDialog file = new OpenFileDialog();
                file.InitialDirectory = "初始目录";
                file.Filter = "你要上传的文件类型";
                file.FilterIndex = 2;
                file.RestoreDirectory = true;
                if (file.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string resultfile = file.FileName;//resultfile就是你选中的文件名
                }
            }
      

  3.   

    http://www.cnblogs.com/allancandy/archive/2010/11/19/1882062.html
      

  4.   

    OpenFileDialog op = new OpenFileDialog();
                op.Title = "导入学生资料";
                op.Filter = "Excel文件(*.xls)|*.xls";
                op.ValidateNames = true;
                op.CheckPathExists = true;
                op.CheckFileExists = true;
                Nullable<bool> result = op.ShowDialog();
      

  5.   

    if (fileDialog.ShowDialog() == DialogResult.OK)//DialogResult)
    这里dialogResult。ok会报一下的错误,换成true就没有问题,也可以运行
    为什么呢?
    using Microsoft.Win32;
    //using System.Windows.Forms;
    用这两个程序集都是这样的问题的,请问。为什么?
    F:\visual studio 2010\projects\Electronic assignments\Electronic assignments\MainWindow.xaml.cs(52,57): 错误 CS1061: “System.Nullable<bool>”不包含“OK”的定义,并且找不到可接受类型为“System.Nullable<bool>”的第一个参数的扩展方法“OK”(是否缺少 using 指令或程序集引用?)
      

  6.   

    fileDialog.ShowDialog()的返回值是Nullable<bool>,也就是说是true或者false,null