コード例 #1
0
 private static bool DownloadDocument(GoogleCloudPrintClient client, Models.Job.Job printJob)
 {
     try
     {
         using (var documentStream = client.GetDocumentAsync(printJob.FileUrl, proxy).Result)
         {
             Directory.CreateDirectory(DocumentFolderPath);
             string path = $"{Path.Combine(DocumentFolderPath, Path.GetFileNameWithoutExtension(printJob.Title))}.pdf";
             using (var fs = File.Create(path))
             {
                 documentStream.CopyTo(fs);
             }
         }
         Console.WriteLine($"Document {printJob.Title} is saved.");
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex.ToString());
         return(false);
     }
     return(true);
 }