我要用,net生成静态网页 能否给点代码

解决方案 »

  1.   


    以前做网站用到了那个。联系我 email:[email protected]
      

  2.   

    我新手写了个 水平低不要建议
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;
    namespace YiYao58
    {
        /*
         * 目前只在html文件中进行过测试
         * ReadFile读取文件要求完整的路径
         * 
         * Replace用于替换文件里面的内容
         * CreateDire 用于创建文件夹
         * WriteFile创建文件和文件夹
         * DelFile 删除文件夹以及里面的内容
         * */
        public class CreateFile
        {
             StringBuilder htmltext = new StringBuilder();
             //读取文件
             public void ReadFile(string FileName)
             {
                             try
                 {                 using (StreamReader sr = new StreamReader(FileName,Encoding.UTF8))
                     {                     String line;                     while ((line = sr.ReadLine()) != null)
                         {                         htmltext.Append(line);                     }                     sr.Close();                 }             }             catch
                 {             } 
             }
             //替换内容
             public void Replace(string oldText,string newText)
             {
                 htmltext.Replace(oldText, newText);
             }
             //创建文件
             public void WriteFile(string FileName)
             {
                 try
                 {                 using (StreamWriter sw = new StreamWriter(FileName, false, System.Text.Encoding.UTF8))
                     {                     sw.WriteLine(htmltext);                     sw.Flush();                     sw.Close();                 }             }             catch
                 {                 } 
             }
             //创建文件夹和文件
             public void CreatFile(string FileName,string Path)
             {
                 try
                 {
                     if (!Directory.Exists(Path))
                     {
                         Directory.CreateDirectory(Path);
                     }                    WriteFile(Path +"\\"+ FileName);             }
                 catch
                 {             }
             }
            //创建文件夹
            public void CreateDire(string Path)
            {
                try
                {
                    if (!Directory.Exists(Path))
                    {
                        Directory.CreateDirectory(Path);
                    }
                
                }
                catch 
                { 
                }
            }
             //删除文件
             public void DelFile(string Path)
             {
                 try
                 {
                     if (Directory.Exists(Path))
                     {
                         Directory.Delete(Path, true);
                     }
                 }
                 catch
                 {
                 }         }
        }
    }
      

  3.   

    看看
    http://www.cnblogs.com/yefei520/archive/2006/02/14/330163.html