首页 > Form窗口时,用ConsoleWriteLine()做什么呢?

Form窗口时,用ConsoleWriteLine()做什么呢?

在InitialDirectory搜索中可以设置打开对话框的初始路径

C# code

private string Road = null;
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.InitialDirectory = "D:\\";
            if (Road != null) { ofd.InitialDirectory = Road ; }
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.Text = ofd.FileName;
                Console.WriteLine(ofd.FileName);

                Road = ofd.FileName.Substring(0,ofd.FileName.LastIndexOf('\\'));
                Console.WriteLine(Road);  
            }
        }

最后一句Console.WriteLine(Road)有什么用?路径显示在哪里了呢?谢谢


当然是写到Console里了。
在C#里,所谓Console,就是指标准输出StandardOutput(除非你做了重定向),对于命令行程序,就是那个黑乎乎的窗口(如果你改了颜色就自己去面壁),对于GUI程序,这个黑乎乎的窗口正常情况下是看不见的,但是如果你在VS里调试程序的话,你可以在调试信息窗口里看见这个信息。

【热门文章】
【热门文章】