private string GetAttachmentTypePath(AttachmentTypesEnum type) { switch (type) { case AttachmentTypesEnum.Products_Categories: return(_settings.AppPathsSettings.Attachments.ProductsCategoriesFolder); case AttachmentTypesEnum.Products: return(_settings.AppPathsSettings.Attachments.ProductsFolder); case AttachmentTypesEnum.Articles_Categories: return(_settings.AppPathsSettings.Attachments.ArticlesCategoriesFolder); case AttachmentTypesEnum.Articles: return(_settings.AppPathsSettings.Attachments.ArticlesFolder); case AttachmentTypesEnum.Banners: return(_settings.AppPathsSettings.Attachments.BannersFolder); case AttachmentTypesEnum.OTrainingProgram: return(_settings.AppPathsSettings.Attachments.OTrainingFolder); default: throw new NotImplementedException(); } }
public bool DeleteFolder(string folderName, AttachmentTypesEnum attachmentType) { try { folderName = Path.Combine(_hostingEnvironment.WebRootPath, GetAttachmentTypePath(attachmentType), folderName); if (Directory.Exists(folderName)) { Directory.Delete(folderName, true); return(true); } return(false); } catch (Exception ex) { _logger.LogError(ex, string.Empty); return(false); } }