<%@ 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
                  {


                      //創(chuàng)建文件夾
                      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");//創(chuàng)建book節(jié)點
                          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>

          posted on 2010-04-08 09:45 sanmao 閱讀(114) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 元谋县| 昭通市| 特克斯县| 和平县| 西平县| 静乐县| 增城市| 郓城县| 无为县| 都昌县| 绍兴市| 高州市| 康乐县| 密山市| 德州市| 咸阳市| 区。| 东港市| 颍上县| 虹口区| 巴林右旗| 宜章县| 民权县| 达拉特旗| 鄂托克旗| 福海县| 铜川市| 大冶市| 广西| 石首市| 莎车县| 新兴县| 盖州市| 汝城县| 饶阳县| 宿州市| 丹寨县| 东光县| 梁山县| 开阳县| 绥中县|