我需要在 Web 用户控件(.NET 4.0、C#、Web 窗体)中创建下拉列表。
此列表应该是 MyPages 文件夹中的 .aspx 列表,放入我的 Web 应用程序中。
如何创建它?我需要读取文件夹-> 文件还是有更好的方法?
最佳答案
像这样的东西应该可以工作:
DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath("/MyPages"));
FileInfo[] fileinfo = directoryInfo.GetFiles("*.aspx");
// do data binding here
关于c# - 如何创建 .aspx 页面列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10062525/