I have this code and I'm getting an IOException and can't figure out what the problem is. I'm trying to loop through the subdirectories in a directory and list all of the .JPG files.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["AllEmpsLoadPath"] = "\\\\intranet.org\\Photo Album\\Employees";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
DirSearch((string)Session["AllEmpsLoadPath"]);
}
void DirSearch(string sDir)
{
foreach (string d in Directory.GetDirectories(sDir))
{
//I get an IOException here on the first iteration
//saying "There are no more files" and f is null
//even though there are subdirectories
foreach (string f in Directory.GetFiles(d, "*.JPG"))
{
BulletedList1.Items.Add(f);
}
DirSearch(d);
}
}