如何创建.aspx页面的列表?
问题描述:
我需要在Web用户控件(.NET 4.0,C#,Web窗体)中创建一个下拉列表。如何创建.aspx页面的列表?
此列表应该是文件夹MyPages中的.aspx列表,放入我的Web应用程序中。
我该如何创建它?我需要阅读文件夹 - >文件或有更好的方法?
答
像这样的东西应该工作:
DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath("/MyPages"));
FileInfo[] fileinfo = directoryInfo.GetFiles("*.aspx");
// do data binding here