string sRootDirectory = Server.MapPath(".").Substring(0, Server.MapPath(".").LastIndexOf(@"\")); ;

string sPath = sRootDirectory + @"\" + "App_Themes";
string[] Themes;
Themes = Directory.GetDirectories(sPath);
int ThemeCount = 0;
ThemeCount = Themes.Length;
string[] ddlThemes = new string[ThemeCount];
int iIndex = 0;
int iCount = 0;
foreach (string Theme in Themes)
{
  iIndex = Theme.LastIndexOf(@"\");
  string sTheme;
  sTheme = Theme.Substring(iIndex + 1);
  ddlThemes[iCount] = sTheme;
  iCount++;
}
//Add theme names in Dropdown for selection
ddlTheme.Items.Add(new ListItem("--Select--", "0"));
foreach (string Theme in ddlThemes)
{
   ddlTheme.Items.Add(new ListItem(Theme, "~/Images/" + Theme + ".jpg"));
}
ddlTheme.DataBind();
ddlTheme.Focus();

Comments (0)