📄 xml.aspx.cs
字号:
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NetCMS.Content;
using System.IO;
public partial class configuration_system_xml : NetCMS.Web.UI.DialogPage
{
public string Str_dirMana = NetCMS.Config.UIConfig.dirDumm;//获取用户虚拟路径
public string str_dirFile = "xml/label/";//获取文件目录
public configuration_system_xml()
{
BrowserAuthor = EnumDialogAuthority.ForAdmin;
}
protected void Page_Load(object sender, EventArgs e)
{
if (str_dirFile == null || str_dirFile.Trim() == "")
{
try
{
Directory.CreateDirectory(Server.MapPath(Str_dirMana + "\\" + str_dirFile));
}
catch (Exception es)
{
PageError(es.ToString(), "");
}
}
if (!IsPostBack)
{
Response.CacheControl = "no-cache";
str_dirFile = str_dirFile + NetCMS.Global.Current.SiteID;
}
string pathtype = Request.QueryString["pathtype"];
string type = Request.QueryString["Type"];
string filesPath = str_dirFile;
string subdirpath = Request.QueryString["subdirpath"];
string parentdirpath = Request.QueryString["parentdirpath"];
string filetype = Request.QueryString["filetype"];
string Path = Request.QueryString["Path"];
switch (type)
{
case "EidtDirName": //修改文件夹名称
EidtDirName(Path);
break;
case "EidtFileName": //修改文件名称
EidtFileName(Path);
break;
case "DelDir": //删除文件夹
DelDir(Path);
break;
case "DelFile": //删除文件
DelFile(Path);
break;
case "AddDir":
AddDir(Path); //添加文件夹
break;
default:
break;
}
ShowFile(filesPath, subdirpath, parentdirpath, filetype);
}
protected void ShowFile(string filesPath, string subdirpath, string parentdirpath, string filetype)
{
if (Str_dirMana.Trim() != "") { Str_dirMana = "\\" + Str_dirMana; }
string filesPath1 = Server.MapPath(Str_dirMana + "\\" + filesPath + "");
string subdirpath1 = Server.MapPath(Str_dirMana + "\\" + filesPath + "\\" + subdirpath + "");
string parentdirpath1 = Server.MapPath(Str_dirMana + "\\" + filesPath + "\\" + parentdirpath + "");
if (!Directory.Exists(filesPath1))
{
try
{
Directory.CreateDirectory(Server.MapPath(Str_dirMana + "\\" + str_dirFile));
}
catch (Exception ep)
{
PageError(ep.ToString(), "");
}
}
if (!Directory.Exists(subdirpath1))
{
PageError("文件目录" + subdirpath + "不存在?。", "");
}
if (filetype == "" || filetype == null)
{
filetype = "xml/label/" + NetCMS.Global.Current.SiteID;
}
File_List.InnerHtml = GetDirFile(subdirpath1, parentdirpath1, filetype, subdirpath, parentdirpath);
}
protected string GetDirFile(string dir, string ParPath, string FileType, string subdirpath, string parentdirpath)
{
if (Str_dirMana == null)
{
Str_dirMana = "/" + Str_dirMana;
}
DirectoryInfo[] ChildDirectory; //子目录集
FileInfo[] NewFileInfo; //当前所有文件
DirectoryInfo FatherDirectory = new DirectoryInfo(dir); //当前目录
ChildDirectory = FatherDirectory.GetDirectories("*.*"); //得到子目录集
NewFileInfo = FatherDirectory.GetFiles(); //得到文件集,可以进行操作
string Str_TempFileStr;
string Str_TrStart = "<tr class=\"TR_BG_list\">";
string Str_TrEnd = "</tr>";
string Str_TempParentstr;
string TempParentPath = dir.Replace("\\", "\\\\"); //路径转意
if (ParPath == "" || ParPath == null || ParPath == string.Empty || ParPath == "undefined")
{
Str_TempParentstr = "当前目录:" + dir;
}
else
{
if (dir == Server.MapPath(Str_dirMana + "\\" + str_dirFile + "\\")) //判断是否是模板目录,如果是则不显示返回上级目录
{
Str_TempParentstr = "<a class=\"list_link\" href=\"javascript:AddDir('" + TempParentPath + Request.QueryString["subdirpath"] + "');\">创建目录</a>┇当前:" + dir;
}
else
{
ParPath = ParPath.Replace("\\", "\\\\");
string Str_strpath = TempParentPath.Remove(TempParentPath.LastIndexOf("\\") - 1);//获取当前目录的上级目录
Str_TempParentstr = "<a href=\"" + Str_dirMana + "/configuration/system/xml.aspx?FileType=" + FileType + "&subdirpath=" + parentdirpath + "&pathtype=" + Request.QueryString["pathtype"] + "\" class=\"list_link\" title=\"点击回到上级目录\">回上级</a>┇<a href=\"javascript:UpFile('" + TempParentPath + Request.QueryString["subdirpath"] + "');\" class=\"list_link\">上传</a>┇<a class=\"list_link\" href=\"javascript:AddDir('" + TempParentPath + Request.QueryString["subdirpath"] + "');\">创建目录</a>┇当前:" + dir;
}
}
Str_TempFileStr = "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
Str_TempFileStr = Str_TempFileStr + Str_TrStart + "<td align=\"left\" colspan=\"5\">" + Str_TempParentstr + Str_TrEnd;
Str_TempFileStr = Str_TempFileStr + "</table>";
Str_TempFileStr = Str_TempFileStr + "<table border=\"0\" class=\"table\" width=\"100%\" cellpadding=\"2\" cellspacing=\"1\">";
Str_TempFileStr = Str_TempFileStr + Str_TrStart + "<td class=\"list_link\">地址:<input class=\"form\" type=\"text\" id=\"sUrl\" name=\"sUrl\" style=\"width:60%\" /> <input type=\"button\" class=\"form\" name=\"Submit\" value=\"选择此文件\" onclick=\"ReturnValue(document.Templetslist.sUrl.value);\" /></td>" + Str_TrEnd;
string str_dirinfo = "";
string str_dirinfo1 = "";
string str_fileinfo = "";
string str_fileinfo1 = "";
foreach (DirectoryInfo dirInfo in ChildDirectory) //获取此级目录下的一级目录
{
string TempPath = dirInfo.FullName.Replace("\\", "\\\\");
str_dirinfo = str_dirinfo + TempPath + ",";
str_dirinfo1 = str_dirinfo1 + dirInfo.Name.ToString() + ",";
str_fileinfo = str_fileinfo + "!@#" + ",";
str_fileinfo1 = str_fileinfo1 + "!@#" + ",";
}
str_dirFile = "/" + str_dirFile;
foreach (FileInfo DirFile in NewFileInfo) //获取此级目录下的所有文件
{
if (SelectFile(DirFile.Extension, FileType)) //传入文件后缀名,判断是否是被显示的文件类型,默认显示html,htm,css
{
str_dirinfo = str_dirinfo + "!@#" + ",";
str_dirinfo1 = str_dirinfo1 + DirFile.Name.ToString() + ",";
str_fileinfo = str_fileinfo + DirFile.Extension.ToLower() + ",";
str_fileinfo1 = str_fileinfo1 + DirFile.Length.ToString() + ",";
}
}
str_dirinfo = NetCMS.Common.Public.Lost(str_dirinfo);
str_dirinfo1 = NetCMS.Common.Public.Lost(str_dirinfo1);
str_fileinfo = NetCMS.Common.Public.Lost(str_fileinfo);
str_fileinfo1 = NetCMS.Common.Public.Lost(str_fileinfo1);
string[] arr_dirinfo = str_dirinfo.Split(',');
string[] arr_dirinfo1 = str_dirinfo1.Split(',');
string[] arr_fileinfo = str_fileinfo.Split(',');
string[] arr_fileinfo1 = str_fileinfo1.Split(',');
string curPage = Request.QueryString["page"]; //当前页码
int pageSize = 20, page = 0; //每页显示数
if (curPage == "" || curPage == null || curPage == string.Empty) { page = 1; }
else
{
try { page = int.Parse(curPage); }
catch
{
page = 0;
}
}
int i, j;
int Cnt = arr_dirinfo.Length;
int pageCount = Cnt / pageSize;
if (Cnt % pageSize != 0) { pageCount++; }
if (page > pageCount) { page = pageCount; }
if (page < 1) { page = 1; }
for (i = (page - 1) * pageSize, j = 1; i < Cnt && j <= pageSize; i++, j++)
{
if (arr_dirinfo[i].ToString() != "!@#")
{
Str_TempFileStr = Str_TempFileStr + Str_TrStart;
Str_TempFileStr = Str_TempFileStr + "<td class=\"list_link\" align=\"left\"><a href=\"javascript:DelDir('" + arr_dirinfo[i].ToString() + "')\"><img src=../../sysimages/folder/del.gif border=\"0\" alt=\"删除\" /></a><img src=\"../../sysImages/FileIcon/folder.gif\" alt=\"点击进入下级目录\"> <a href=\"" + Str_dirMana + "/configuration/system/xml.aspx?FileType=" + FileType + "&pathtype=" + Request.QueryString["pathtype"] + "&subdirpath=" + (subdirpath + "/" + arr_dirinfo1[i].ToString()).ToString().Replace("//", "/") + "&parentdirpath=" + Request.QueryString["subdirpath"] + "\"\" target=\"select_main\" class=\"list_link\" title=\"点击进入下级目录\">" + arr_dirinfo1[i].ToString() + "</a></td>";
Str_TempFileStr = Str_TempFileStr + Str_TrEnd;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -