CTA.WebForms.ProjectManagement.ProjectBuilder.DeleteFileAndEmptyDirectories C# (CSharp) Method

DeleteFileAndEmptyDirectories() public method

public DeleteFileAndEmptyDirectories ( string filePath, string pathLimit ) : void
filePath string
pathLimit string
return void
        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}");
            }
        }
    }