public List <HttpFolderInfo> GetDirectories(string folderPath, string rootPath) { StringBuilder stringBuilder = new StringBuilder(); string queryString = GameRequest.GetQueryString("order"); List <HttpFolderInfo> httpFolderInfos = new List <HttpFolderInfo>(); IList <FolderInfo> directoryFilesListForObject = FileManager.GetDirectoryFilesListForObject(folderPath, FsoMethod.All); if (directoryFilesListForObject == null || directoryFilesListForObject.Count <= 0) { this.m_access = false; return(httpFolderInfos); } foreach (FolderInfo folderInfo in directoryFilesListForObject) { stringBuilder.Remove(0, stringBuilder.Length); if (folderInfo.FsoType == FsoMethod.Folder) { stringBuilder.AppendFormat("<a href=\"Web_FilesManager.aspx?path={0}\">", Utility.UrlEncode(string.Concat(rootPath, "/", folderInfo.Name))).AppendFormat("<img src=\"images/attach/files/folder.gif\" alt=\"文件夹\" align=\"absmiddle\" /> {0} </a>", folderInfo.Name).AppendFormat(" <a href=\"Web_FilesManager.aspx?act=compress&path={0}&objfolder={1}\" onclick=\"javascript:compressMsg();\">", Utility.UrlEncode(this.m_folderPath), Utility.UrlEncode(folderInfo.FullName)); HttpFolderInfo httpFolderInfo = new HttpFolderInfo(folderInfo.Name, Utility.UrlEncode(folderInfo.FullName), stringBuilder.ToString(), "", (long)0, "folder", folderInfo.LastWriteTime); httpFolderInfos.Add(httpFolderInfo); HttpFileManager mFolderCount = this; mFolderCount.m_folderCount = mFolderCount.m_folderCount + 1; } if (folderInfo.FsoType != FsoMethod.File) { continue; } if (!TextUtility.InArray(folderInfo.ContentType, "jpg,gif,png,bmp,psd", ",", true)) { stringBuilder.AppendFormat("<a href=\"file.axd?file={0}\" target=\"_new\">", Utility.UrlEncode(string.Concat(rootPath, "/", folderInfo.Name))); string contentType = "default"; string str = folderInfo.ContentType; string str1 = str; if (str != null) { switch (str1) { case "mp3": case "wav": case "wma": case "wmv": { contentType = "mp3"; break; } case "zip": case "7z": case "rar": { contentType = "zip"; break; } } } if (!TextUtility.EmptyTrimOrNull(folderInfo.ContentType) && TextUtility.InArray(folderInfo.ContentType, "css,dll,doc,docx,swf,txt,xls,xlsx,xml", ",", true)) { contentType = folderInfo.ContentType; } stringBuilder.AppendFormat("<img src=\"images/attach/files/{1}.gif\" alt=\"文件\" align=\"absmiddle\" /> {0}</a>", folderInfo.Name, contentType); } else { stringBuilder.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"showPopWin('Web_FilesView.aspx?url=file.axd?file={0}',700,433,null);\">", Utility.UrlEncode(string.Concat(rootPath, "/", folderInfo.Name))).AppendFormat("<img src=\"images/attach/files/{1}.gif\" alt=\"文件\" align=\"absmiddle\" /> {0}</a>", folderInfo.Name, folderInfo.ContentType); } HttpFolderInfo httpFolderInfo1 = new HttpFolderInfo(folderInfo.Name, Utility.UrlEncode(folderInfo.FullName), stringBuilder.ToString(), folderInfo.ContentType, folderInfo.Length, "file", folderInfo.LastWriteTime); httpFolderInfos.Add(httpFolderInfo1); HttpFileManager mFileCount = this; mFileCount.m_FileCount = mFileCount.m_FileCount + 1; } this.m_access = true; if (!TextUtility.EmptyTrimOrNull(queryString)) { httpFolderInfos.Sort(new FilesComparer(queryString)); } return(httpFolderInfos); }
public List <HttpFolderInfo> GetDirectories(string folderPath, string rootPath) { StringBuilder stringBuilder = new StringBuilder(); string queryString = GameRequest.GetQueryString("order"); List <HttpFolderInfo> list = new List <HttpFolderInfo>(); IList <FolderInfo> directoryFilesListForObject = FileManager.GetDirectoryFilesListForObject(folderPath, FsoMethod.All); if (directoryFilesListForObject == null || directoryFilesListForObject.Count <= 0) { m_access = false; return(list); } foreach (FolderInfo item3 in directoryFilesListForObject) { stringBuilder.Remove(0, stringBuilder.Length); if (item3.FsoType == FsoMethod.Folder) { stringBuilder.AppendFormat("<a href=\"Web_FilesManager.aspx?path={0}\">", Utility.UrlEncode(rootPath + "/" + item3.Name)).AppendFormat("<img src=\"images/attach/files/folder.gif\" alt=\"文件夹\" align=\"absmiddle\" /> {0} </a>", item3.Name).AppendFormat(" <a href=\"Web_FilesManager.aspx?act=compress&path={0}&objfolder={1}\" onclick=\"javascript:compressMsg();\">", Utility.UrlEncode(m_folderPath), Utility.UrlEncode(item3.FullName)); HttpFolderInfo item = new HttpFolderInfo(item3.Name, Utility.UrlEncode(item3.FullName), stringBuilder.ToString(), "", 0L, "folder", item3.LastWriteTime); list.Add(item); m_folderCount++; } if (item3.FsoType == FsoMethod.File) { if (TextUtility.InArray(item3.ContentType, "jpg,gif,png,bmp,psd", ",", true)) { stringBuilder.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"showPopWin('Web_FilesView.aspx?url=file.axd?file={0}',700,433,null);\">", Utility.UrlEncode(rootPath + "/" + item3.Name)).AppendFormat("<img src=\"images/attach/files/{1}.gif\" alt=\"文件\" align=\"absmiddle\" /> {0}</a>", item3.Name, item3.ContentType); } else { stringBuilder.AppendFormat("<a href=\"file.axd?file={0}\" target=\"_new\">", Utility.UrlEncode(rootPath + "/" + item3.Name)); string arg = "default"; switch (item3.ContentType) { case "mp3": case "wav": case "wma": case "wmv": arg = "mp3"; break; case "zip": case "7z": case "rar": arg = "zip"; break; } if (!TextUtility.EmptyTrimOrNull(item3.ContentType) && TextUtility.InArray(item3.ContentType, "css,dll,doc,docx,swf,txt,xls,xlsx,xml", ",", true)) { arg = item3.ContentType; } stringBuilder.AppendFormat("<img src=\"images/attach/files/{1}.gif\" alt=\"文件\" align=\"absmiddle\" /> {0}</a>", item3.Name, arg); } HttpFolderInfo item2 = new HttpFolderInfo(item3.Name, Utility.UrlEncode(item3.FullName), stringBuilder.ToString(), item3.ContentType, item3.Length, "file", item3.LastWriteTime); list.Add(item2); m_FileCount++; } } m_access = true; if (!TextUtility.EmptyTrimOrNull(queryString)) { list.Sort(new FilesComparer(queryString)); } return(list); }