这是书上的一个例子,我照抄下来运行,结果出错。
这个小程序就是简单运用OpenFileDialog类,实现显示标准的Windows"打开"对话框。可是书上原原本本的例子难道有错?using System;
using System.Windows.Forms;class Example15_1
{
public static void Main()
{
//create and show an open file dialog
OpenFileDialog dlgOpen = new OpenFileDialog();
if (dlgOpen.ShowDialog() == DialogResult.OK)
{
Console.Write(dlgOpen.FileName);
}
}
}网上查了结果是:在控制台程序中不能引用System.Windows.Forms命名空间。那么请问各位高手,如果我想在控制台实现这个功能应该怎么改这个程序?谢谢~!
这个小程序就是简单运用OpenFileDialog类,实现显示标准的Windows"打开"对话框。可是书上原原本本的例子难道有错?using System;
using System.Windows.Forms;class Example15_1
{
public static void Main()
{
//create and show an open file dialog
OpenFileDialog dlgOpen = new OpenFileDialog();
if (dlgOpen.ShowDialog() == DialogResult.OK)
{
Console.Write(dlgOpen.FileName);
}
}
}网上查了结果是:在控制台程序中不能引用System.Windows.Forms命名空间。那么请问各位高手,如果我想在控制台实现这个功能应该怎么改这个程序?谢谢~!
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://feiyun0112.cnblogs.com/
把System.Windows.Forms.dll拷贝到你的源文件下