C#中在.xhtml文件中include的html文件,生成出现的空格问题

当需要在.xhtml页面中引用html文件时,在生成html文件需要生成为【不带签名】的html,否则在生成的html文件中有空格,这样会影响页面的布局

 

代码如下:希望大家可以多多指教

 

  private void CreateTopCityHtml()    

     {          

   string cityHtml = GetTopCityHtml();   //获取html片段     

     string strLAWebRoot = System.Configuration.ConfigurationManager.AppSettings["root"].ToString();//从web.config中读取的

            string savePath = strLAWebRoot + "\\html\\index\\city\\";   

          if (!System.IO.Directory.Exists(savePath))         

    {                

System.IO.Directory.CreateDirectory(savePath);       

      }            

string fileName = "topcity.htm";       

      string filepath = Path.Combine(savePath, fileName);       

      UTF8Encoding utf8 = new UTF8Encoding(false);  //不带签名的    

       using (StreamWriter streamWriter = new StreamWriter(filepath, false, utf8)) //保存地址        

     {                

streamWriter.WriteLine(cityHtml);      

           streamWriter.Flush();        

         streamWriter.Close();    

         }    

     }

posted @ 2013-04-10 13:19  郭二的  阅读(182)  评论(0编辑  收藏  举报