如何创建动态html表单并保存在文件夹中... [英] How to create Dynamic html form and save in folder...

查看:83
本文介绍了如何创建动态html表单并保存在文件夹中...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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());
                }
            }



i想创建.htm文件,我必须动态地将该.htm文件存储在同一个项目中。

任何人都可以帮我......几个小时挣扎......


i want to create .htm file and i have to store that .htm file in that same project dynamically..
Can any one help me..am struggling for couple of hours...

推荐答案

你可以用c#或php或cgi
当您需要在源代码中回显或打印dhtm文本时,您需要使用哪种格式?
you can create it with c# or php or cgi
when you need in your source you echo or print the text of dhtm with format you need
which language you want to do it ?


DONE BRO..FINALLY我就是这样...



DONE BRO..FINALLY I GOT LIKE THIS...

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);
            }


这篇关于如何创建动态html表单并保存在文件夹中...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆