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>

  • 相关阅读:
    【转载】java调用C++写的DLL
    【转载】Java实现word转pdf
    【原创】由一件匪夷所思的事情所想到的
    【原创】不定字段的数据库表设计思路
    【原创】IBM Websphere 报错:JSPG0120E: 为 pageEncoding 属性和匹配 URI 模式的配置元素指定不同的值是非法的。
    weblogic <BEA-000438>
    svn报错 400 Bad Request
    实习技术知识点
    重写HashMap
    QUnit利用代理测试不同PHP开发服务器的json服务
  • 原文地址:https://www.cnblogs.com/bestsaler/p/1835509.html
Copyright © 2011-2022 走看看