`

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

分享到:
评论

相关推荐

    FCK编辑器谷歌地图插件 for pjblog.rar

    首先请下载谷歌地图插件文件包,解压后整个目录上传到FCK编辑器目录下的editor\plugins目录下 然后,打开FCK编辑器目录下的fckconfig.js文件,找到如下一句代码 FCKConfig.PluginsPath = FCKConfig.BasePath '...

    fckedit编辑器

    &lt;FCK:editor basePath="/TestFCKeditor/FCKeditor/" width="700" height="500" skinPath="/TestFCKeditor/FCKeditor/editor/skins/silver/" toolbarSet = "Default" &gt; input &lt;/FCK:editor&gt; --%&gt; //JS...

    FCK在线编辑器源码及部署项目引用示例

    4.将以下代码添加到web.xml配置文件中: &lt;servlet-name&gt;Connector com.FCKeditor.connector.ConnectorServlet &lt;param-name&gt;baseDir &lt;param-value&gt;/upload/ &lt;param-name&gt;debug &lt;param-value&gt;true ...

    FCKeditor.Java 2.4 源代码

    [#2412] FCK.InsertHtml() is now properly removing selected contents after content insertion in Firefox. [#2420] Spelling mistake corrections made by the spell checking dialog are now undoable. [#...

    生成缩略图插件ver1.2 for PHPCMS3.0.rar

    修改压缩包内的fckeditor\editor\dialog\fck_image.html 查找 &lt;input name="thumbWidth" id="thumbWidth" type="text" value="450" size="5" /&gt; 修改value值为自己想要的默认宽度 自定义原图HTML边框: ...

    Fckeditor2.6.4插件 for pjblog

    开启方法:打开fckeditor\editor\filemanager\connectors\asp\config.asp在其中找到代码:Dim ConfigIsEnabled ConfigIsEnabled = false将false改为true 上传文件目录的修改方法是在此文件中找到代码:Dim ...

    PJBLOG3海神扩展增强版3.0.6.170

    3、为什么上传程序后页面无法正常显示,提示错误代码 请执行生clearache.asp重建缓存,如果执行一还不能正常显示,请多执行几次,直到能正常显示为止 PJBLOG3海神扩展增强包扩展功能介绍: 一、pjblog3最终版补丁...

    fckeditor扩展上传文件、源码高亮,插入Flash、媒体及视频及集成轻开平台

    首先需要说明的是,与通常意义上的编辑器不同,FCKeditor并不是一个需要安装的程序,或许说它是一个网页源代码更为贴切,所以,取而代之安装过程的是与网页源代码相集成的调用过程。 FCKeditor运行的环境是网页...

    ASP.NET2.0典型模块(17-22)ASP.NET2.0典型模块(1-16)

    FCKEditorSample FCK编辑器的使用示例 FreeTextBoxSample FreeText编辑器的使用示例 SimpleEditor 自定义的简单在线编辑器模块 &lt;br&gt;第7章(\C07) 示例描述:本章示例展现了C#中的字符串操作。...

    ASP.NET2.0典型模块(1-16)

    FCKEditorSample FCK编辑器的使用示例 FreeTextBoxSample FreeText编辑器的使用示例 SimpleEditor 自定义的简单在线编辑器模块 &lt;br&gt;第7章(\C07) 示例描述:本章示例展现了C#中的字符串操作。...

Global site tag (gtag.js) - Google Analytics