public void DeleteTransient(TransientAvatarDescriptor transientAvatar) { if (transientAvatar == null) { throw new ArgumentNullException(nameof(transientAvatar)); } var fullPath = Path.Combine(this.webRootPath, transientAvatar.RelativeFileName); File.Delete(fullPath); }
public async Task CommitTransient(TransientAvatarDescriptor transientAvatar) { var fullTransientAvatarPath = Path.Combine(this.webRootPath, transientAvatar.RelativeFileName); if (!File.Exists(fullTransientAvatarPath)) { throw new InvalidOperationException($"Transient file '{transientAvatar.RelativeFileName} not found'"); } var fullAvatarPath = Path.Combine(this.webRootPath, transientAvatar.TargetRelativeFileName); using (FileStream transientStream = new(fullTransientAvatarPath, FileMode.Open)) using (FileStream avatarStream = new(fullAvatarPath, FileMode.Create)) await transientStream.CopyToAsync(avatarStream); File.Delete(fullTransientAvatarPath); }