Hi, I have a problem on this code bellow, here I'm trying to Delete a Folder (Album ) Which has so many pictures. I have set the Album from image from a different folder (tempFolder) and i have used a third party dll which just take the ImageFolderPath to show the images on a thikbox popup. My problem is this when ever I'm trying to delete a Album its throing an exception as 'File can not be delete it's currently used by another process'. So Please help me how to delete a folder which is used by another process or not empty..
string SavePath = Server.MapPath("~/" + Convert.ToString(iPlayConstant._USERTYPE) + "/Gallery/" + Convert.ToString(iPlayConstant._USERID) + "/" + Convert.ToString(e.CommandArgument) + "/");
DirectoryInfo di = new DirectoryInfo(SavePath);
try
{
if (e.CommandName == "Delete Album")
{
if (di.Exists)
{
FileInfo[] fi = di.GetFiles();
for (int i = 0; i < fi.Length; i++)
{
try
{
fi[i].Delete();
}
catch (Exception ex1) { }
}
di.Delete();
}
}
catch (Exception ex) { }
Thanks Bishnu