You have to add a reference to the System.Windows.Forms
assembly.
Also, you must add the STAThread
attribute to your application entry point method.
[STAThread]
private static void Main(string[] args)
{
using (SaveFileDialog sFile = new SaveFileDialog())
{
sFile.ShowDialog();
}
Console.ReadKey();
}
But honestly, that's a terrible idea. A console application shouldn't have any other UI that the console itself. As the namespace of SaveFileDialog
suggests, SaveFileDialog
should be used for Forms
only.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…