コード例 #1
0
        public void DeleteTransient(TransientAvatarDescriptor transientAvatar)
        {
            if (transientAvatar == null)
            {
                throw new ArgumentNullException(nameof(transientAvatar));
            }

            var fullPath = Path.Combine(this.webRootPath, transientAvatar.RelativeFileName);

            File.Delete(fullPath);
        }
コード例 #2
0
        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);
        }