各位大侠~我的程序代码如下: 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
那个路径我用绝对路径的话是没问题的~
{
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
那个路径我用绝对路径的话是没问题的~
string path = Server.MapPath("~/")