• 安装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>

  • 相关阅读:
    iPad----------教你如何查询ipad型号
    博客园:教你如何给一篇博客加入外链
    Github:failed to add file / to index
    iOS----------教你如何使用 GitHub Desktop
    iOS----------调用系统照相机和相册
    iOS 10 设备权限问题(相机,相册等)
    iOS----------UITextField实现过滤选中状态拼音
    【2020Python修炼记】MySQL之 数据备份、pymysql模块
    【2020Python修炼记】MySQL之 SQL查询应用
    【CMD的使用技巧与语法】
  • 原文地址:https://www.cnblogs.com/bestsaler/p/1835509.html
Copyright © 2020-2023  润新知