void btnDelete_Click(object sender, EventArgs e) { try { bool isDeleted = false; foreach (GridDataItem data in grid.SelectedItems) { int intNewsID = Convert.ToInt32(data.GetDataKeyValue("NewsID")); int newsCommentID = Convert.ToInt32(data.GetDataKeyValue("NewsCommentID")); string virtualPath = NewsHelper.AttachmentsPath(siteSettings.SiteId, intNewsID); string fileSystemPath = HostingEnvironment.MapPath(virtualPath); try { NewsHelper.DeleteDirectory(fileSystemPath); } catch (Exception ex) { try { System.Threading.Thread.Sleep(0); Directory.Delete(fileSystemPath, false); } catch (Exception) { } } News.DeleteNewsComment(newsCommentID); isDeleted = true; } if (isDeleted) { PopulateControls(); } } catch (Exception ex) { log.Error(ex); } }