/// <summary> /// Delete a picture on file system /// </summary> /// <param name="picture">Picture</param> protected virtual void DeletePictureOnFileSystem(Picture picture) { if (picture == null) { throw new ArgumentNullException(nameof(picture)); } string lastPart = GetFileExtensionFromMimeType(picture.MimeType); string fileName = $"{picture.Id:0000000}_0.{lastPart}"; string filePath = GetPictureLocalPath(fileName); _fileProvider.DeleteFile(filePath); }
/// <summary> /// Delete the file /// </summary> /// <param name="path">Path to the file</param> /// <returns>A task that represents the completion of the operation</returns> protected virtual async Task DeleteFileAsync(string path) { path = GetFullPath(GetVirtualPath(path)); if (!_fileProvider.FileExists(path)) { throw new Exception(GetLanguageResource("E_DeleteFileInvalidPath")); } try { _fileProvider.DeleteFile(path); await HttpContext.Response.WriteAsync(GetSuccessResponse()); } catch { throw new Exception(GetLanguageResource("E_DeletŠµFile")); } }