public void DeleteFileAndEmptyDirectories(string filePath, string pathLimit)
{
if (!File.Exists(filePath))
{
return;
}
try
{
var parentDir = Path.GetDirectoryName(filePath);
File.Delete(filePath);
DeleteDirectoriesIfEmpty(parentDir, pathLimit);
}
catch (Exception e)
{
LogHelper.LogError(e, $"{Rules.Config.Constants.WebFormsErrorTag}Unable to delete file at {filePath}");
}
}
}