|
代码如下:
string file = @"D:\a.html";
if (File.Exists(file))
{
StreamWriter sw = File.AppendText(file); //执行到这提示文件拒绝访问
sw.WriteLine("<table border='1'>");
sw.WriteLine(foundHtml);
sw.WriteLine("</table>");
sw.WriteLine("<table border='1'>");
sw.WriteLine(authorHtml);
sw.WriteLine("</table>");
sw.WriteLine("<table border='1'>");
sw.WriteLine(serviceHtml);
sw.WriteLine("</table>");
sw.Close(); //关闭流
sw.Dispose(); //销假对象
}
else
{
StreamWriter sw = File.CreateText(file);//文件拒绝访问
sw.WriteLine("<table border='1'>");
sw.WriteLine(foundHtml);
sw.WriteLine("</table>");
sw.WriteLine("<table border='1'>");
sw.WriteLine(authorHtml);
sw.WriteLine("</table>");
sw.WriteLine("<table border='1'>");
sw.WriteLine(serviceHtml);
sw.WriteLine("</table>");
sw.Close();
sw.Dispose();
} 怎么解决啊??
|
|