void ShowDir() { string strServer = Request.Form["tip"]; if (strServer == null || (strServer = strServer.Trim()) == string.Empty) { strServer = "127.0.0.1"; } string maindir = (Request.Form["dir"] ?? @"E:\WebLogs").TrimEnd('\\', '/'); bool showMd5 = (Request.Form["md5"] ?? "") == "1"; int sortTmp; int.TryParse(Request.Form["sort"] ?? "0", out sortTmp); SortType sort = (SortType)sortTmp; string msg; FileResult result = TaskClient.GetDir(strServer, 23244, maindir, sort, showMd5, out msg); if (!string.IsNullOrEmpty(msg)) { Response.Write(msg); return; } StringBuilder sbRet = new StringBuilder("<span style='font-weight:bold;color:red;'>"); sbRet.AppendFormat("{0} dirs, {1} files. server time:{2}. {3}", result.SubDirs.Length.ToString(), result.SubFiles.Length.ToString(), result.ServerTime.ToString("yyyy-MM-dd HH:mm:ss_fff"), result.Others); string parentDir = (Path.GetDirectoryName(maindir) ?? "").Replace(@"\", @"\\"); string rootDir = maindir.Length > 3 ? maindir.Substring(0, 2) : ""; string currentdir = maindir.Replace(@"\", @"\\"); sbRet.AppendFormat(@"</span> <table border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed;' class='filetb' id='tbFileManager'> <tr style='background-color:#96d9f9'> <th style='width:130px; text-align:left;'> <label><input type='checkbox' onclick=""chgChkColor($('#divFileRet input[type=checkbox]'), this.checked);"" />全选</label> <a href='javascript:void(0);' onclick='OpenCheckOption();'>条件</a> <br /> <label><input type='checkbox' onclick='CheckAllDir(this);' />目录</label> <label><input type='checkbox' onclick='CheckAllFile(this);' />文件</label> </th> <th style='width:370px; text-align:left;'> [<a href='javascript:void(0);' onclick='fileOpenDir(""{0}"");'>上级目录</a>] [<a href='javascript:void(0);' onclick='fileOpenDir(""{1}"");'>根目录</a>] </th> <th style='width:50px;'>扩展名</th> <th style='width:70px;'>大小(byte)</th> <th style='width:150px;'>修改日期</th>{2}<th>序<br/>号</th> </tr> ", parentDir, rootDir, (showMd5 ? "<th>MD5</th>" : "")); int idx = 1; string[] colors = new string[] { "#ffffff", "#dadada" };//f0f0f0 // 绑定目录列表 foreach (FileItem dir in result.SubDirs) { sbRet.AppendFormat(@" <tr style='height:20px;background-color:{3}' onmouseover='onRowOver(this);' onmouseout='onRowOut(this);' onclick='onRowClick(this);'> <td style='text-align:left;'> <label><input type='checkbox' value='{0}' name='chkDirListBeinet' /></label> <a href='javascript:void(0);' onclick=""fileReName('{0}', 0);"" tabindex='-1'>改名</a>|<a href='javascript:void(0);' onclick=""fileDel('{0}', 0);"" tabindex='-1'>删除</a>|<a href='javascript:void(0);' onclick='dirZipDown(""{0}"");' tabindex='-1'>ZIP</a> </td> <td style='text-align:left; font-weight:bold;'><a href='javascript:void(0);' onclick=""fileOpenDir('{4}\\{0}');"" tabindex='-1'>{0}</a></td> <td style='text-align:center;'>目录</td> <td style='text-align:center;'><a href='javascript:void(0);' onclick=""countDirSize('{0}');"" tabindex='-1'>计算大小</a></td> <td style='text-align:center;'>{1}</td>" + (showMd5 ? "<td></td>" : "") + @"<th>{2}</th> </tr> ", dir.Name, dir.LastModifyTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), idx, colors[idx % 2], currentdir); idx++; } // 绑定文件列表 foreach (FileItem file in result.SubFiles) { sbRet.AppendFormat(@" <tr style='height:22px;background-color:{6}' onmouseover='onRowOver(this);' onmouseout='onRowOut(this);' onclick='onRowClick(this);'> <td style='text-align:left;'> <label><input type='checkbox' value='{0}' name='chkFileListBeinet' /></label> <a href='javascript:void(0);' onclick=""fileReName('{0}', 1);"" tabindex='-1'>改名</a>|<a href='javascript:void(0);' onclick=""fileDel('{0}', 1);"" tabindex='-1'>删</a>|<a href='javascript:void(0);' onclick='fileDownOpen(""{0}"");' tabindex='-1'>下</a>|<a href='javascript:void(0);' onclick='fileDownOpen(""{0}"",1);' tabindex='-1'>开</a> </td> <td style='text-align:left;'>{0}</td> <td style='text-align:center;'>{1}</td> <td style='text-align:right;'>{2}</td> <td style='text-align:center;'>{3}</td>{4} <th>{5}</th> </tr> ", file.Name, Path.GetExtension(file.Name), file.Size.ToString("N0"), file.LastModifyTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), (showMd5 ? "<td style='text-align:right;'>" + file.FileMd5 + "</th>" : ""), idx, colors[idx % 2]); idx++; } Response.Write(sbRet.ToString()); }