小旋锋 2010-03-30
由于我这边的网络原因,没用从FCK的官网下载到源码...
这套源码是FCK2.2版反编译出来的
源码:点此下载 源码中主要修改的地方做了注释
大致的修改如下 :
获取用户目录的源码: FileWorkerBase.cs
这里主要是做了一些注释
在程序中可以直接在用户登录的时候指定
这个方案只是方便多用户使用的时候为用户指定不同的文件目录
Session["FCKeditor:UserFilesPath"]="用户文件相对目录";
代码如下:
/// <summary> /// 用户文件目录 /// </summary> protected string UserFilesPath { get { if (this.sUserFilesPath == null) { //从APPlictaion 读取 this.sUserFilesPath = (string)base.Application["FCKeditor:UserFilesPath"]; if ((this.sUserFilesPath == null) || (this.sUserFilesPath.Length == 0)) { //从Session读取 this.sUserFilesPath = (string)this.Session["FCKeditor:UserFilesPath"]; if ((this.sUserFilesPath == null) || (this.sUserFilesPath.Length == 0)) { //从站点配置文件读取 this.sUserFilesPath = ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"]; if ((this.sUserFilesPath == null) || (this.sUserFilesPath.Length == 0)) { this.sUserFilesPath = "/UpLoadFiles/"; } if ((this.sUserFilesPath == null) || (this.sUserFilesPath.Length == 0)) { //从URL读取 this.sUserFilesPath = base.Request.QueryString["ServerPath"]; } } } if (!this.sUserFilesPath.EndsWith("/")) { this.sUserFilesPath = this.sUserFilesPath + "/"; } } return this.sUserFilesPath; } }
代码如下:
/// <summary> /// 根据文件类型选择文件夹 /// </summary> /// <param name="resourceType"></param> /// <param name="folderPath"></param> /// <returns></returns> private string ServerMapFolder(string resourceType, string folderPath) { //2010-3-29 14:00:56 //string path = Path.Combine(base.UserFilesDirectory, resourceType); string path = base.UserFilesDirectory; Util.CreateDirectory(path); return Path.Combine(path, folderPath.TrimStart(new char[] { '/' })); }
代码如下:
private string GetUrlFromPath(string resourceType, string folderPath) { if ((resourceType == null) || (resourceType.Length == 0)) { return (base.UserFilesPath.TrimEnd(new char[] { '/' }) + folderPath); } //2010-3-29 14:00:20 HYZ //return (base.UserFilesPath + resourceType + folderPath); string p=base.UserFilesPath + folderPath;//新增 p=p.Replace("//","/");//新增 return (p);//新增 }