Displaying all the aspx page in dropdownlist
Code as follows
Code as follows
string sourceDirectory = Server.MapPath("~/"); DirectoryInfo directoryInfo = new DirectoryInfo(sourceDirectory);
var aspxFiles = new List
(Directory.GetFiles(sourceDirectory,"*.aspx",SearchOption.AllDirectories));
for (int i = 0;i
{ string[] smsg = aspxFiles[i].Split('\\'); int a = smsg.Count();
sourceDirectory = smsg[a - 1].ToString().Trim(); this.dropdownlist1.Items.Add(sourceDirectory);
}
from the above code displaying all the aspx page into dropdownlist
i have one folder called Employee.
in Employee folder Two aspx page as follows
Emplogin.aspx and Empmaster.aspx
In the dropdownlist1 i am displaying .aspx page. but i dont want to show the above Employee folder two aspx page
Emplogin.aspx and Empmaster.aspx dont want to show in the dropdownlist1.
for that how can i do in asp.net using c#.
Manas MohapatraPosted Dec 31, 2015, 2:16 AM
You need to change SearchOption.AllDirectories to SearchOption.TopDirectoryOnly which will search only current directory not subdirectory.