我写了自己的第一个才c#程序。功能是从指定网站中抓取信息保存在本地文本文档中.把本来是Form1.cs的编译成Form1.exe。运行后出现了两个问题
1,我运行Form1.exe的时候会的当前界面背后出现一个讨厌的dos界面。
如果我是在c盘根目录下面运行Form1.exe,dos界面的标题栏就写成是C:\Form1.exe.这个窗口怎么能不出来2.程序一运行我就不能控制拖动界面了(好象是程序死了一样,但是其实还在运行),大概持续要运行一分钟,只能等抓取信息完成了后才能得到控制权。
程序获取的数据流可能有点大,但是这个问题有如何解决了。

解决方案 »

  1.   

    Form1.exe是不是dos程序,还是winForm形式的?
      

  2.   

    你的winForm有界面么,设计的时候有界面么,还是只是一段c#代码编译成的exe,如果是一段c#编译成的exe,应该有DOS窗口的
      

  3.   

    主要代码如下:namespace WindowsApplication1
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Button button1;
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public Form1()
    {
    InitializeComponent(); } protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.button1 = new System.Windows.Forms.Button();
    this.SuspendLayout();
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(192, 152);
    this.button1.Name = "button1";
    this.button1.TabIndex = 0;
    this.button1.Text = "搜索";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    //  
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(272, 269);
    this.Controls.Add(this.button1);
    this.Name = "Form1";
    this.Text = "Form1";
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void button1_Click(object sender, System.EventArgs e)
    {  //我写的全部只在这个Click事件中
    string url="一个网站的网址";
    StreamWriter sw = new StreamWriter("E:\\1.txt");
    string content=getbody(url);  //这里是我写的一个方法,调用指定网站源码                      …………………………………………//中间省略对content的编辑处理
    sw.Write(str1);
    sw.Close();
    }
    }