void CreateTempFile() { string DirectoryName = String.Format("Templates.{0}", Path.GetFileNameWithoutExtension(FileName)); //目标文件夹 string CopyToPath = String.Format("{0}/Templates.{1}", Server.MapPath(Constants.TempBasePath), Path.GetFileNameWithoutExtension(FileName)); //源文件夹 string CopyFromPath = TemplateHelper.TemplateGroupPath; CopyFromPath = String.Format("{0}/{1}", CopyFromPath, Path.GetFileNameWithoutExtension(FileName)); CopyToPath = String.Format("{0}/{2}/Skin/{1}", CopyToPath, Path.GetFileNameWithoutExtension(FileName), DirectoryName); //复制模板文件夹 CopyFolder(CopyToPath, CopyFromPath, true); //预览图片源 string JpgFile = String.Format("{0}.xml.jpg", CopyFromPath); //Xml文件源 string XmlFile = String.Format("{0}.xml", CopyFromPath); CopyToPath = String.Format("{0}/Templates.{1}", Server.MapPath(Constants.TempBasePath), Path.GetFileNameWithoutExtension(FileName));//目标文件夹 //复制XML文件、预览图片 if (File.Exists(JpgFile)) { string str = String.Format("{0}/{2}/Skin/{1}.xml.jpg", CopyToPath, Path.GetFileNameWithoutExtension(FileName), DirectoryName); File.Copy(JpgFile, str, true); } if (File.Exists(XmlFile)) { File.Copy(XmlFile, String.Format("{0}/{2}/Skin/{1}", CopyToPath, FileName, DirectoryName), true); } //创建res文件夹 //string resPath = String.Format("{0}/res", CopyToPath); //Directory.CreateDirectory(resPath); //创建版本文件 //CreateVersion(resPath); //TODO:css、ascx文件路径处理 //打包 string[] FileProperties = new string[2]; FileProperties[0] = CopyToPath; //压缩目录 FileProperties[1] = String.Format("{0}/Templates.{1}.zip", Server.MapPath(Constants.TempBasePath), Path.GetFileNameWithoutExtension(FileName)); //压缩后的目录 //压缩文件 try { ZipClass.CreateTemplateZip(FileProperties); DonwloadHyperLink.NavigateUrl = String.Format("~/{0}/Templates.{1}.zip", Constants.TempBasePath.TrimStart('/').TrimStart('\\'), Path.GetFileNameWithoutExtension(FileName)); DeleteFolder(CopyToPath); } catch { } }