StringBuilder sb = new StringBuilder(); sb.Append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd \"> \r\n "); sb.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n"); sb.Append("<head>\r\n"); sb.Append("<meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" />\r\n"); sb.Append("<title>My HTMl Page</title>\r\n"); sb.Append("</head>\r\n"); sb.Append("<body>\r\n"); sb.Append("<table>\r\n"); //If you are emiting some data like a list of items foreach (var item in Items) { sb.Append("<tr>\r\n"); sb.Append("<td>\r\n"); sb.Append(item.ToString()); sb.Append("</td>\r\n"); sb.Append("</tr>\r\n"); } sb.Append("</table>\r\n"); sb.Append("</body>\r\n"); sb.Append("</html>\r\n"); using (FileStream fs = new FileStream("HTMLLLLLLLLLLLL.htm", FileMode.Create)) { using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8)) { w.WriteLine(sb.ToString()); } }
string path = "CopyHtml.htm"; byte[] b = System.Text.Encoding.UTF8.GetBytes(html.ToString()); // This text is added only once to the file. if (!File.Exists(path)) { File.WriteAllBytes(Server.MapPath(path), b); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)