Esempio n. 1
0
        async Task <string> IFileGateway.GetFileContentAsync(
            string filePath,
            CancellationToken ct)
        {
            var path = Path.Combine(_rootFolder, filePath);
            var text = await File.ReadAllTextAsync(
                path,
                Encoding.UTF8,
                CancellationTokenHelper.MergeCancellationToken(ct, TIMEOUT));

            return(text);
        }
Esempio n. 2
0
        async Task IFileGateway.SetFileContentAsync(
            string filePath,
            string content,
            CancellationToken ct)
        {
            var path      = Path.Combine(_rootFolder, filePath);
            var directory = Path.GetDirectoryName(path);

            if (!string.IsNullOrWhiteSpace(directory))
            {
                EnsureDirectoryExists(directory);
            }

            await File.WriteAllTextAsync(
                path,
                content,
                CancellationTokenHelper.MergeCancellationToken(ct, TIMEOUT));
        }