protected void EBtnNewDir_Click(object sender, EventArgs e) { if (this.Page.IsValid) { try { DirectoryInfo info = new DirectoryInfo(this.currentDirectory + @"\" + this.TxtNewDir.Text); if (info.Exists) { AdminPage.WriteErrMsg("新建的目录已经存在", this.m_UrlReferrer); } FileSystemObject.Create(this.currentDirectory + @"\" + this.TxtNewDir.Text, FsoMethod.Folder); base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>"); AdminPage.WriteSuccessMsg("新建目录成功", this.m_UrlReferrer); } catch (FileNotFoundException) { AdminPage.WriteErrMsg("文件未找到", this.m_UrlReferrer); } catch (UnauthorizedAccessException) { AdminPage.WriteErrMsg("<li>新建目录失败!检查您的服务器是否给模板文件夹写入权限。</li>", this.m_UrlReferrer); } } }
protected void btnCreateFolder_Click(object sender, EventArgs e) { //string pattern = "^[a-zA-Z0-9_]+$"; //if (!Regex.IsMatch(this.txtForderName.Text.Trim(), pattern, RegexOptions.IgnoreCase)) //{ // function.WriteErrMsg("<li>文件夹名称不能有特殊字符!</li><li><a href='javascript:window.history.back(-1)'>返回</a></li>"); //} this.AbsPath = this.HdnPath.Value; if (this.Page.IsValid) { try { DirectoryInfo info = new DirectoryInfo(this.AbsPath + @"\" + this.txtForderName.Text.Trim()); if (info.Exists) { function.WriteErrMsg("当前目录下已存在同名的文件夹", this.m_UrlReferrer); } FileSystemObject.Create(this.AbsPath + @"\" + this.txtForderName.Text.Trim(), FsoMethod.Folder); function.WriteSuccessMsg("文件夹创建成功!", this.m_UrlReferrer); } catch (FileNotFoundException) { function.WriteErrMsg("无法在目标位置创建文件夹!", this.m_UrlReferrer); } catch (UnauthorizedAccessException) { function.WriteErrMsg("<li>在目标位置没有权限创建文件夹!</li>", this.m_UrlReferrer); } } }
private void WriteXML(string cxml) { string filename = "Create_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".config"; FileSystemObject.Create(Server.MapPath("/Config/" + filename), FsoMethod.File); //创建任务对应的XML XmlDocument xml = new XmlDocument(); xml.LoadXml(cxml.ToString()); xml.Save(HttpContext.Current.Server.MapPath("/Config/" + filename)); }
protected void Button1_Click(object sender, EventArgs e) { DataSet ds = this.bll.GetAllLabel(); string filename = base.Request.PhysicalApplicationPath + @"\" + "App_Data" + @"\" + "LabelExport.xml"; if (!FileSystemObject.IsExist(filename, FsoMethod.File)) { FileSystemObject.Create(filename, FsoMethod.File); } this.Label1.Text = "开始导出"; ds.WriteXml(filename); this.Label1.Text = "成功!"; }
private bool CreateAndCheckFolderPermission(SpecialCategoryInfo categoryInfo) { string file = VirtualPathUtility.AppendTrailingSlash(this.PhysicalApplicationPath) + VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + categoryInfo.SpecialCategoryDir; if (!FileSystemObject.IsExist(file, FsoMethod.Folder)) { try { FileSystemObject.Create(file, FsoMethod.Folder); } catch { string errMsg = string.Concat(new object[] { "专题类别ID为:", categoryInfo.SpecialCategoryId, " ", categoryInfo.SpecialCategoryName, " 生成失败! 失败原因:请检查服务器是否给网站", SiteConfig.SiteOption.CreateHtmlPath, "文件夹写入权限!" }); this.ErrorLog(errMsg); return(false); } } return(true); }
private bool CreateAndCheckFolderPermission(SpecialInfo specialInfo) { string file = VirtualPathUtility.AppendTrailingSlash(this.PhysicalApplicationPath) + VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + specialInfo.SpecialDir; if (!FileSystemObject.IsExist(file, FsoMethod.Folder)) { try { FileSystemObject.Create(file, FsoMethod.Folder); } catch { string errMsg = "专题ID:" + specialInfo.SpecialId.ToString() + " " + specialInfo.SpecialName + " 生成失败! 失败原因:请检查服务器是否给网站" + SiteConfig.SiteOption.CreateHtmlPath + "文件夹写入权限!"; this.ErrorLog(errMsg); return(false); } } return(true); }
protected void Page_Load(object sender, EventArgs e) { function.AccessRulo(); B_Admin badmin = new B_Admin(); B_Admin.CheckIsLogged(); Call.SetBreadCrumb(Master, "<li>后台管理</li><li>CRM应用</li><li><a href='ProjectsModel.aspx'>项目模型</a></li>"); if (!this.Page.IsPostBack) { if (!File.Exists(HttpContext.Current.Server.MapPath("~/Images/ModelIcon/"))) { FileSystemObject.Create(HttpContext.Current.Server.MapPath("~/Images/ModelIcon/"), FsoMethod.Folder); } foreach (DataRow row in FileSystemObject.GetDirectoryInfos(HttpContext.Current.Server.MapPath("~/Images/ModelIcon/"), FsoMethod.File).Rows) { this.DrpItemIcon.Items.Add(new ListItem(row["name"].ToString(), row["name"].ToString())); } this.DrpItemIcon.Attributes.Add("onchange", "ChangeImgItemIcon(this.value);ChangeTxtItemIcon(this.value);"); this.TxtItemIcon.Attributes.Add("onchange", "ChangeImgItemIcon(this.value);"); string id = base.Request.QueryString["ModelID"]; if (!string.IsNullOrEmpty(id)) { this.HdnModelId.Value = id; this.LTitle.Text = "修改项目模型"; M_ModelInfo info = this.bll.GetModelById(int.Parse(id)); this.TxtModelName.Text = info.ModelName; this.LblTablePrefix.Visible = false; this.TxtTableName.Text = info.TableName; this.TxtTableName.Enabled = false; this.TxtItemName.Text = info.ItemName; this.TxtItemUnit.Text = info.ItemUnit; string selectValue = string.IsNullOrEmpty(info.ItemIcon) ? "Default.gif" : info.ItemIcon; //this.ImgItemIcon.ImageUrl = "~/Images/ModelIcon/" + selectValue; this.DrpItemIcon.SelectedValue = selectValue; this.TxtItemIcon.Text = info.ItemIcon; this.TxtDescription.Text = info.Description; } else { this.HdnModelId.Value = "0"; } } }
public virtual void ErrorLog(string errMsg) { string file = this.m_MapPath + "Admin/CreateHtmlLog/" + this.CreateId + ".txt"; if (!FileSystemObject.IsExist(this.m_MapPath + "Admin/CreateHtmlLog", FsoMethod.Folder)) { FileSystemObject.Create(this.m_MapPath + "Admin/CreateHtmlLog", FsoMethod.Folder); } if (FileSystemObject.IsExist(file, FsoMethod.File)) { FileSystemObject.WriteAppend(file, "\r\n" + errMsg); } else { FileSystemObject.Create(file, FsoMethod.File); FileSystemObject.WriteFile(file, "生成时间:" + this.CreateStartTime.ToString() + "\r\n" + errMsg); } this.m_CreateHasNewError = true; }
protected void BtnDW_Click(object sender, EventArgs e) { string str2 = HttpContext.Current.Server.MapPath("~/" + SiteConfig.SiteOption.LabelDir); if (!FileSystemObject.IsExist(str2 + @"\Dreamweaver", FsoMethod.Folder)) { FileSystemObject.Create(str2 + @"\Dreamweaver", FsoMethod.Folder); if (!FileSystemObject.IsExist(str2 + @"\Dreamweaver\_folderinfo.txt", FsoMethod.File)) { FileSystemObject.Create(str2 + @"\Dreamweaver\_folderinfo.txt", FsoMethod.File); FileSystemObject.WriteFile(str2 + @"\Dreamweaver\_folderinfo.txt", "PE2007标签"); } } foreach (LabelManageInfo info in LabelManage.GetLabelList(string.Empty)) { StringBuilder builder = new StringBuilder(); IList <LabelAttributeInfo> attributeList = LabelManage.GetAttributeList(str2 + @"\" + info.Name + ".config"); if (!FileSystemObject.IsExist(str2 + @"\Dreamweaver\" + info.Name + ".csn", FsoMethod.File)) { FileSystemObject.Create(str2 + @"\Dreamweaver\" + info.Name + ".csn", FsoMethod.File); } builder.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); builder.Append("<snippet name = \"" + info.Name + "\" description = \"" + info.Intro + "\" preview=\"code\" type=\"block\">\n"); builder.Append("<insertText location=\"beforeSelection\">\n"); builder.Append("<![CDATA[{PE.Label "); builder.Append("id=\"" + info.Name + "\""); foreach (LabelAttributeInfo info2 in attributeList) { builder.Append(" " + info2.AttributeName + "=\"" + info2.DefaultValue + "\""); } builder.Append(" /}]]>\n"); builder.Append("</insertText>\n"); builder.Append("<insertText location=\"afterSelection\"><![CDATA[]]>\n"); builder.Append("</insertText>\n"); builder.Append("</snippet>\n"); FileSystemObject.WriteFile(str2 + @"\Dreamweaver\" + info.Name + ".csn", builder.ToString()); } PackFiles(str2 + @"\Dreamweaver.zip", str2 + @"\Dreamweaver"); if (!ResponseFile(this.Page.Request, this.Page.Response, "PE2007_DwPlus.zip", str2 + @"\Dreamweaver.zip", 0xfa000L)) { base.Response.Write("下载文件出错!"); } }
protected void btnCreateFolder_Click(object sender, EventArgs e) { try { string ppath = function.VToP(TemplateDir); DirectoryInfo info = new DirectoryInfo(ppath + "\\" + this.txtForderName.Text.Trim()); if (info.Exists) { function.WriteErrMsg(Resources.L.当前目录下已存在同名的文件夹); } FileSystemObject.Create(ppath + @"\" + this.txtForderName.Text.Trim(), FsoMethod.Folder); function.WriteSuccessMsg(Resources.L.文件夹创建成功 + "!"); } catch (FileNotFoundException) { function.WriteSuccessMsg(Resources.L.文件夹创建成功 + "!"); } catch (UnauthorizedAccessException) { function.WriteSuccessMsg(Resources.L.没有权限创键文件夹 + "!"); } }
protected void EBtnSubmit_Click(object sender, EventArgs e) { string pronametxt = this.proname.Text; string protypetxt = this.protype.Text; int ornumtxt = DataConverter.CLng(this.ornum.Text); string tempname = tempdirlist.SelectedValue; string tempimgtxt = ""; string author = txtAuthor.Text.Trim() == "" ? "佚名" : txtAuthor.Text.Trim(); string tempdir = SiteConfig.SiteOption.TemplateDir; string[] temparr = tempdir.Split(new string[] { @"/" }, StringSplitOptions.None); string template = SiteConfig.SiteMapath() + temparr[1]; string infofile = template + "\\" + tempname + @"\Info.config"; if (!FileSystemObject.IsExist(infofile, FsoMethod.File)) { FileSystemObject.Create(infofile, FsoMethod.File); DataSet projectSet = new DataSet("NewDataSet"); DataTable projecttable = new DataTable(); projecttable.TableName = "Table"; projecttable.Columns.Add("Project", typeof(string)); projecttable.Columns.Add("TempDirName", typeof(string)); projecttable.Columns.Add("Author", typeof(string)); projecttable.Columns.Add("ProType", typeof(string)); projecttable.Columns.Add("OrderNum", typeof(string)); projecttable.Columns.Add("ProjectImg", typeof(string)); projecttable.Columns.Add("isinstall", typeof(string)); DataRow rows = projecttable.NewRow(); rows["Project"] = pronametxt; rows["ProType"] = protypetxt; rows["OrderNum"] = ornumtxt; rows["Author"] = author; rows["TempDirName"] = tempname; rows["ProjectImg"] = tempimgtxt; rows["isinstall"] = "true"; projecttable.Rows.Add(rows); projectSet.Tables.Add(projecttable); projectSet.WriteXml(infofile); } else { DataSet projectSet = new DataSet("NewDataSet"); DataTable projecttable = new DataTable(); projecttable.TableName = "Table"; projecttable.Columns.Add("Project", typeof(string)); projecttable.Columns.Add("TempDirName", typeof(string)); projecttable.Columns.Add("Author", typeof(string)); projecttable.Columns.Add("ProType", typeof(string)); projecttable.Columns.Add("OrderNum", typeof(string)); projecttable.Columns.Add("ProjectImg", typeof(string)); projecttable.Columns.Add("isinstall", typeof(string)); DataRow rows = projecttable.NewRow(); rows["Project"] = pronametxt; rows["ProType"] = protypetxt; rows["Author"] = author; rows["OrderNum"] = ornumtxt; rows["TempDirName"] = tempname; rows["ProjectImg"] = tempimgtxt; rows["isinstall"] = "true"; projecttable.Rows.Add(rows); projectSet.Tables.Add(projecttable); projectSet.WriteXml(infofile); } if (!FileSystemObject.IsExist(SiteConfig.SiteMapath() + "config/TemplateProject.config", FsoMethod.File)) { DataSet projectSet = new DataSet("NewDataSet"); DataTable projecttable = new DataTable(); projecttable.TableName = "Table"; projecttable.Columns.Add("Project", typeof(string)); projecttable.Columns.Add("TempDirName", typeof(string)); projecttable.Columns.Add("Author", typeof(string)); projecttable.Columns.Add("ProType", typeof(string)); projecttable.Columns.Add("OrderNum", typeof(string)); projecttable.Columns.Add("ProjectImg", typeof(string)); DataRow rows = projecttable.NewRow(); rows["Project"] = pronametxt; rows["ProType"] = protypetxt; rows["Author"] = author; rows["OrderNum"] = ornumtxt; rows["TempDirName"] = tempname; rows["ProjectImg"] = tempimgtxt; projecttable.Rows.Add(rows); projectSet.Tables.Add(projecttable); projectSet.WriteXml(SiteConfig.SiteMapath() + "config/TemplateProject.config"); } else { DataSet projectSet = new DataSet("NewDataSet"); projectSet.ReadXml(SiteConfig.SiteMapath() + "config/TemplateProject.config"); if (projectSet == null) { projectSet = new DataSet("NewDataSet"); } if (projectSet.Tables.Count > 0) { DataTable tables = projectSet.Tables[0].Copy(); for (int i = 0; i < tables.Rows.Count; i++) { if (tables.Rows[i]["Project"].ToString().Trim() == pronametxt.Trim()) { ClientScript.RegisterStartupScript(this.GetType(), "", "alert('名称已存在,请重新填写!');document.getElementById('" + proname.ClientID + "').focus();", true); return; } else if (tables.Rows[i]["TempDirName"].ToString().Trim() == tempname) { ClientScript.RegisterStartupScript(this.GetType(), "", "alert('选中模板已发布,请重新选择!');document.getElementById('" + tempdirlist.ClientID + "').focus();", true); return; } } tables.TableName = "Table"; DataRow rows = tables.NewRow(); rows["Project"] = pronametxt; rows["TempDirName"] = tempname; rows["Author"] = author; rows["ProType"] = protypetxt; rows["OrderNum"] = ornumtxt; rows["ProjectImg"] = tempimgtxt; tables.Rows.Add(rows); DataSet projectSetcs = new DataSet("NewDataSet"); projectSetcs.Tables.Add(tables); projectSetcs.WriteXml(SiteConfig.SiteMapath() + "config/TemplateProject.config"); } else { DataTable tables = new DataTable(); tables.TableName = "Table"; tables.Columns.Add(new DataColumn("Project", typeof(string))); tables.Columns.Add(new DataColumn("TempDirName", typeof(string))); tables.Columns.Add(new DataColumn("Author", typeof(string))); tables.Columns.Add(new DataColumn("ProType", typeof(string))); tables.Columns.Add(new DataColumn("OrderNum", typeof(string))); tables.Columns.Add(new DataColumn("ProjectImg", typeof(string))); DataRow rows = tables.NewRow(); rows["Project"] = pronametxt; rows["ProType"] = protypetxt; rows["OrderNum"] = ornumtxt; rows["Author"] = author; rows["TempDirName"] = tempname; rows["ProjectImg"] = tempimgtxt; tables.Rows.Add(rows); DataSet projectSetcs = new DataSet("NewDataSet"); projectSetcs.Tables.Add(tables); projectSetcs.WriteXml(SiteConfig.SiteMapath() + "config/TemplateProject.config"); } } function.WriteSuccessMsg("操作成功!", "TemplateSet.aspx"); }
public void CreateFile(M_Node nodeMod) { string UName = this.TxtNodeDir.Text.Trim(); string Ulook = ""; if (!string.IsNullOrEmpty(Ulook)) { if (RadioButtonList1.SelectedValue == "0") { if (Ulook.IndexOf("http://") == -1) { Ulook = "http://" + Ulook; } } if (RadioButtonList1.SelectedValue == "1") { if (Ulook.IndexOf("~/") == -1) { Ulook = "~/" + Ulook; } } string USend = "~/ColumnList.aspx?NodeID=" + nodeMod.NodeID; #region 文件生成 USend = Ulook; string AbsPath = base.Request.PhysicalApplicationPath; if (USend.IndexOf("http://") > -1) { if (USend.IndexOf("/", 8) > -1 && USend.Length > USend.IndexOf("/", 8) + 1) { string USend2 = USend.Substring(USend.IndexOf("/", 8)); if (USend2.IndexOf(".") > -1) { USend2 = USend2.Substring(USend2.IndexOf(".")); } else { #region 文件生成 try { DirectoryInfo info = new DirectoryInfo(AbsPath + USend2 + @"\Default.aspx"); if (info.Exists) { // Response.Write("<script>alert('文件以');</script>"); } else { FileSystemObject.Create(AbsPath + USend2 + @"\Default.aspx", FsoMethod.File); FileSystemObject.Create(AbsPath + USend2 + @"\Index.aspx", FsoMethod.File); } } catch (FileNotFoundException) { function.WriteErrMsg("发生错误"); } catch (UnauthorizedAccessException) { function.WriteErrMsg("发生错误"); } #endregion } } } else { string USend3 = USend.Substring(2); if (USend.IndexOf(".") > -1) { // USend = USend.Substring(USend.IndexOf(".")); // Response.Write("<script>alert('" + USend3 + "');</script>"); } else { #region 文件生成 try { DirectoryInfo info = new DirectoryInfo(AbsPath + USend3); if (info.Exists) { // Response.Write("<script>alert('aa');</script>"); } else { FileSystemObject.Create(AbsPath + USend3 + @"\Default.aspx", FsoMethod.File); FileSystemObject.Create(AbsPath + USend3 + @"\Index.aspx", FsoMethod.File); } } catch (FileNotFoundException) { function.WriteErrMsg("发生错误"); } catch (UnauthorizedAccessException) { function.WriteErrMsg("发生错误"); } #endregion } } #endregion } if (DropDownList1.SelectedValue != "0") { M_Pub pm = pll.GetSelect(DataConverter.CLng(DropDownList1.SelectedValue)); pm.PubNodeID = nodeMod.NodeID.ToString(); pll.GetUpdate(pm); } }