zoukankan      html  css  js  c++  java
  • 安装fck editor 的程序代码

    <%@ Page Language="C#" AutoEventWireup="true"%>
    <%@ Import Namespace="System.Xml" %>
     CodeBehind="install.aspx.cs" Inherits="WebApplication1.fckeditor.install"
    <script type="text/C#" runat="server">
        public string basePath = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {

            basePath = Request.PhysicalApplicationPath.ToString();


        }
        public bool SettingConfig(string uploadfile)
        {
            bool state = false;
            try
            {


                //创建文件夹
                if (!System.IO.Directory.Exists(basePath + uploadfile))
                    System.IO.Directory.CreateDirectory(basePath + uploadfile);

                string basePathConfig = basePath + "Web.config";
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(basePathConfig); //加载你的XML文件
                XmlNode appSettings = xmlDoc.SelectSingleNode("/configuration/appSettings");//查找bookstore

                string[,] strs = new string[2, 2] { { "FCKeditor:BasePath", "/fckeditor/" }, { "FCKeditor:UserFilesPath", "/" + uploadfile + "/" } };
                for (int i = 0; i < 2; i++)
                {
                    XmlElement adds = xmlDoc.CreateElement("add");//创建book节点
                    adds.SetAttribute("key", strs[i, 0]);
                    adds.SetAttribute("value", strs[i, 1]);
                    appSettings.AppendChild(adds);
                }

                xmlDoc.Save(basePathConfig);
                state = true;
            }
            catch (Exception ex)
            {

                Response.Write(ex.Message);
            }
            return state;

        }
        public bool SetingJavaScript()
        {
            bool state = false;
            string tempContent = string.Empty;
            try
            {
                using (System.IO.StreamReader sr = new System.IO.StreamReader(basePath + "fckeditor\\fckconfig.js", System.Text.Encoding.UTF8))
                {
                    tempContent = sr.ReadToEnd();
                    sr.Close();
                }
                tempContent = tempContent.Replace("FCKConfig.DefaultLanguage  = 'en' ;", "FCKConfig.DefaultLanguage  = 'zh-cn' ;").Replace("var _FileBrowserLanguage = 'asp' ;", "var _FileBrowserLanguage = 'aspx' ;").Replace("var _QuickUploadLanguage = 'asp' ;", "var _QuickUploadLanguage = 'aspx' ;");
                using (System.IO.StreamWriter sw = new System.IO.StreamWriter(basePath + "fckeditor\\fckconfig.js", false, System.Text.Encoding.UTF8))
                {
                    sw.Write(tempContent);
                    sw.Flush();
                }
                state = true;

            }
            catch (Exception ex)
            {

                Response.Write(ex.Message);
            }

            return state;
        }
        public bool CopyFile()
        {
            try
            {
                if (System.IO.File.Exists(basePath + "bin\\FredCK.FCKeditorV2.dll"))
                    System.IO.File.Delete(this.basePath + "fckeditor\\bin\\FredCK.FCKeditorV2.dll");
                else
                    System.IO.File.Copy(this.basePath + "fckeditor\\bin\\FredCK.FCKeditorV2.dll", basePath + "bin\\FredCK.FCKeditorV2.dll");
            }
            catch (Exception ex)
            {

                Response.Write(ex.Message);
                return false;
            }

            return true;
        }

        protected void BtSave_Click(object sender, EventArgs e)
        {
            SettingConfig(this.TbUploadPath.Text);
            SetingJavaScript();
            CopyFile();
            Response.Write("success");
        }
    </script>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
       
            上传文件夹路径: <asp:TextBox ID="TbUploadPath" runat="server"></asp:TextBox>
            <br />
            <asp:Button ID="BtSave" runat="server" Text="保存" style="border:1px solid"
                onclick="BtSave_Click" />
       
        </div>
        </form>
    </body>
    </html>

  • 相关阅读:
    [ jquery 选择器 :hidden ] 此方法选取匹配所有不可见元素,或者type为hidden的元素
    剑指 Offer 03. 数组中重复的数字 哈希
    LeetCode 1736. 替换隐藏数字得到的最晚时间 贪心
    Leetcode 1552. 两球之间的磁力 二分
    Leetcode 88. 合并两个有序数组 双指针
    LeetCode 1744. 你能在你最喜欢的那天吃到你最喜欢的糖果吗?
    LeetCode 1743. 相邻元素对还原数组 哈希
    LeetCode 1745. 回文串分割 IV dp
    剑指 Offer 47. 礼物的最大价值 dp
    剑指 Offer 33. 二叉搜索树的后序遍历序列 树的遍历
  • 原文地址:https://www.cnblogs.com/bestsaler/p/1835509.html
Copyright © 2011-2022 走看看