2009-11-12 59 views

回答

3

要列出文件和文件夾,你可以使用一種叫做DirectoryInfo

例如

void Page_Load(object s, EventArgs e) 
{ 
DirectoryInfo di = new DirectoryInfo("c:/inetpub/wwwroot/demos"); 
FileInfo[] rgFiles = di.GetFiles("*.aspx"); 
foreach(FileInfo fi in rgFiles) 
{ 
    Response.Write("<br><a href=" + fi.Name + ">" + fi.Name + "</a>");  
} 
} 

example taken from here