http://bbs.5liao.cc/viewthread.php?tid=7&extra=
也许这个可以帮助楼主

解决方案 »

  1.   

    生成文件
    if (System.IO.Directory.Exists(Server.MapPath("~/adjunct")) == false) //如果不存在,创建文件夹
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath("~/adjunct"));//创建文件夹
                        }
      

  2.   


      public static void MakeDir(string newsKind,DateTime dt)
        {
            //按照年月日创建文件夹
            string strfolder = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString();
            Scripting.FileSystemObject fso = new Scripting.FileSystemObjectClass();
            if (!fso.FolderExists(HttpContext.Current.Server.MapPath("~/pages/" + strfolder)))
            {
                fso.CreateFolder(HttpContext.Current.Server.MapPath("~/pages/" + strfolder));
            }
            if(!fso.FolderExists(HttpContext.Current.Server.MapPath("~/pages/" + strfolder + "/" + newsKind)))
            {
                fso.CreateFolder(HttpContext.Current.Server.MapPath("~/pages/" + strfolder + "/" + newsKind));
            }
        }
      

  3.   

     /// <summary>
            /// 目录生成器
            /// </summary>
            /// <param name="_applicationpath">服务器程序路径</param>
            /// <param name="directoryname">建立的目录类型名称</param>
            /// <returns></returns>
            public static string DirectoryBuilder(string _applicationpath, string directoryname)
            {
                try
                {
                    if (!System.IO.Directory.Exists(_applicationpath + @"News"))
                    {
                        System.IO.Directory.CreateDirectory(_applicationpath + @"News");
                    }                string date = DateTime.Now.ToString("yyyyMMdd");
                    string path = _applicationpath + @"News";
                    string filepath = path + "\\" + directoryname + "\\" + date;
                    System.IO.Directory.CreateDirectory(filepath);
                    return filepath = @"News"+"\\" + directoryname + "\\" + date;            }            catch(System.Exception ex)
                {
                    throw new Exception(ex.Message);
                }        }
      

  4.   


    先判断adjunct这个文件夹是否存在,不存在就创建。你每天一个文件夹,文件夹名可以取对应日期。