各位大侠~我的程序代码如下: private void downloadHtml(string url, Encoding encoding)
    {
        try
        {
            string result = GetHtmlCode(url, Encoding.UTF8);
            string path = Server.MapPath(".") + "/result" + _count + ".html";
            FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs, encoding);
            sw.Write(result);
            sw.Flush();
            sw.Close();
        }
        catch (System.Exception ex)
        { Console.WriteLine(ex.Message); 
        }
    
    }为什么会说+$exception {"未将对象引用设置到对象的实例。"} System.Exception 
那个路径我用绝对路径的话是没问题的~

解决方案 »

  1.   

    哎,你可以下断点的
     
    string path = Server.MapPath("~/") 
      

  2.   

    string path = Server.MapPath("./")   + "result" + _count + ".html";试一下啊
      

  3.   

    你在winform里头用 Server.MapPath 么?
      

  4.   

    我设置断点了,可是临时变量里竟然不显示path的值,还有用string path = Server.MapPath("./") + "result" + _count + ".html";也是不好用~
      

  5.   

    FileStream生成失败?还是看下路径吧