예제 #1
0
 public Task <IStream> OpenRead(string path)
 {
     using (_logger.BeginScope("{Operation} is {Action} {path}", nameof(FileProxy),
                               "opening a read stream for", path))
     {
         var stream = new StreamProxy(File.OpenRead(path)) as IStream;
         _logger.LogInformation("Opened a read stream for the file");
         return(Task.FromResult(stream));
     }
 }
예제 #2
0
 public Task <IStream> OpenWrite(string path)
 {
     using (_logger.BeginScope("{Operation} is {Action} {path}", nameof(FileProxy),
                               "opening a write stream for", path))
     {
         var directory = path.Substring(0, path.LastIndexOf('\\'));
         Directory.CreateDirectory(directory);
         _logger.LogTrace("The file will be put in the the folder {folder}", directory);
         var stream = new StreamProxy(File.OpenWrite(path)) as IStream;
         _logger.LogInformation("Opened a write stream for the file");
         return(Task.FromResult(stream));
     }
 }