2012-04-08 62 views
2

我需要在Web用戶控件(.NET 4.0,C#,Web窗體)中創建一個下拉列表。如何創建.aspx頁面的列表?

此列表應該是文件夾MyPages中的.aspx列表,放入我的Web應用程序中。

我該如何創建它?我需要閱讀文件夾 - >文件或有更好的方法?

回答

8

像這樣的東西應該工作:

DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath("/MyPages")); 
FileInfo[] fileinfo = directoryInfo.GetFiles("*.aspx"); 

// do data binding here