日期:2014-05-17 浏览次数:20513 次
<%@ Page Language="C#" AutoEventWireUp="true" %>
<%@ import Namespace="System.Threading" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="ComponentArt.Web.UI" %>
<% Response.ContentType = "text/xml"; %>
<script language="C#" runat="server">
void Page_Load(Object sender,EventArgs e)
{
ComponentArt.Web.UI.TreeView TreeView1 = new ComponentArt.Web.UI.TreeView();
string dirPath = Request.QueryString["dir"];
dirPath = dirPath.Replace("~", "\\");
// Don't allow browsing the file system outside of the app root
if (dirPath.StartsWith(Request.MapPath("~")))
{
string[] subDirectories = Directory.GetDirectories(dirPath);
foreach (string directory in subDirectories)
{
string[] parts = directory.Split('\\');
string name = parts[parts.Length-1];
ComponentArt.Web.UI.TreeViewNode node = new ComponentArt.Web.UI.TreeViewNode ();
node.Text = name;
node.ContentCallbackUrl = "XmlFromFileSystem.aspx?dir=" + directory.Replace("\\", "~");
node.ID = directory.Replace("\\", "~");
TreeView1.Nodes.Add(node);
}
Response.Write(TreeView1.GetXml());
}
}
</script>