日期:2014-05-17  浏览次数:21191 次

FolderBrowserDialog 选取文件并返回文件路径时报错
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;

namespace ExcelToBom
{
  /// <summary>
  /// MainWindow.xaml 的交互逻辑
  /// </summary>
  public partial class MainWindow : Window
  {
  public MainWindow()
  {
  InitializeComponent();
  }

  private void button1_Click(object sender, RoutedEventArgs e)
  {
  //From:QQ吻's Blog http://qqhack8.blog.163.com
  FolderBrowserDialog myDialog = new FolderBrowserDialog();

  myDialog.ShowNewFolderButton = false;

  myDialog.Description = "选择你要设置的文件夹或目录 ";

  if (myDialog.ShowDialog() == DialogResult.OK)

  this.textBox1.Text = myDialog.SelectedPath;

  myDialog.Dispose(); 
  }
  }
}


提示以下错误:
“System.Nullable<bool>”不包含“OK”的定义,并且找不到可接受类型为“System.Nullable<bool>”的第一个参数的扩展方法“OK”(是否缺少 using 指令或程序集引用?)