public void Delete(DesktopFile request)
        {
            AssertFile(request.File);

            var appSettingsDir = GetDesktopFilesDirectory();
            var filePath       = Path.Combine(appSettingsDir, request.File);

            try { File.Delete(filePath); } catch {}
        }
        public async Task Get(DesktopFile request)
        {
            AssertFile(request.File);

            var appSettingsDir = GetDesktopFilesDirectory();
            var filePath       = Path.Combine(appSettingsDir, request.File);

            using var fs = new FileInfo(filePath).OpenRead();
            if (fs == null)
            {
                throw new FileNotFoundException();
            }

            Response.ContentType = MimeTypes.GetMimeType(filePath);
            await Response.EndRequestAsync(afterHeaders : async res => {
                await fs.CopyToAsync(Response.OutputStream);
            });
        }
        public async Task Put(DesktopFile request)
        {
            AssertFile(request.File);

            var appSettingsDir = GetDesktopFilesDirectory();

            FileSystemVirtualFiles.AssertDirectory(appSettingsDir);

            var filePath    = Path.Combine(appSettingsDir, request.File);
            var tmpFilePath = Path.Combine(appSettingsDir, request.File + ".tmp");

            try { File.Delete(tmpFilePath); } catch {}
            using (var fs = new FileInfo(tmpFilePath).Open(FileMode.OpenOrCreate))
            {
                await request.RequestStream.CopyToAsync(fs);
            }
            try { File.Delete(filePath); } catch {}
            File.Move(tmpFilePath, filePath);
        }
 public Task Post(DesktopFile request) => Put(request);