我在编一个程序,中间想用控制台看看我截取的数据对不对,对的话再继续写后面的程序。想用控制台显示出我截取的字符串,但是传入控制台输出语句写了之后,运行调试没有反应,大家遇到过这样的情况没有?语句检查没有错误啊                string strFileName = "";
                for (int i = 0; i < dlg.FileNames.GetLength(0); i++)
                    strFileName += dlg.FileNames[i];
                MessageBox.Show(this, strFileName, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);//显示选择文件信息
                string strFileName1 = Path.GetFullPath(strFileName);
                FileStream gFile = new FileStream(strFileName1, FileMode.Open, FileAccess.Read, FileShare.None);
                gFile.Seek(20, SeekOrigin.Begin);
                StreamReader sr = new StreamReader(gFile);
                string strLine = sr.ReadLine();
                while (strLine != null)
                {
                    Console.WriteLine(strLine);
                    strLine = sr.ReadLine();
                 }
                sr.Close();
                gFile.Close();

解决方案 »

  1.   

    Debug.WriteLine();
    Debug.WriteLineIf();
    Trace.WriteLine();
    Trace.WriteLineIf();MessageBox.Show
      

  2.   

    gui 程序默认没有控制台, 控制台 I/O 不可用
      

  3.   

    debug和trace语句用了之后,还是没有反应
    请问二位大哥 代码该如何修改,让我能看到输出   谢谢了
      

  4.   

    .net 不是留了一个接口来调用控制台吗? 望赐教
      

  5.   

    找找 AttachConsole API,如果只是显示几个东西, 没必在 GUI 程序中使用控制台 i/o .