直播中
<%@ Import Namespace="System.IO" %>
<html>
<title>DataGrid 巧用實現(xiàn) 目錄瀏覽?。?!</title>
<script language="C#" runat="server">
void Page_Load(Object Src, EventArgs E){
ArrayList ar = new ArrayList();
Directory[] dirs = Directory.GetDirectoriesInDirectory(Server.MapPath("/"));
foreach (Directory dir in dirs) {
foreach (File f in dir.GetFiles("*.aspx")) //如果是 想要 列出別的類型的文件,只要修改這個就可以了
{
ar.Add(f.Name);
}
}
dg.DataSource = ar;
dg.DataBind();
}
</script>
</head>
<body>
<form method="post" runat="server">
<asp:DataGrid
Id="dg"
Runat="Server"
headerstyle-backcolor="#666699"
headerstyle-forecolor="#FFFFFF"
itemstyle-backcolor ="#EEEEEE"
alternatingitemstyle-backcolor="#FFFFFF"
alternatingitemstyle-forecolor="#000000"
/>
</form>
</body>