title: c# adobe acrobat SDK: file is still locked after SDK quit
body: <p>I'm working with C# and adobe acrobat SDK.
  When the program throws an error due to the pdf already being compressed I want to move the pdf.</p>
  <p>However, C# complains that the file is being used by another process and I know it has to do with the SDK and not another program.
  After some debugging I found out that <code>compressPDFOperation.Execute</code> is the culprit.</p>
  <p>How can I close it so that I can move the file?</p>
  <pre><code> try {
  
   // Initial setup, create credentials instance.
              Console.WriteLine(&quot;.json: &quot; + Directory.GetCurrentDirectory() + &quot;/pdftools-api-credentials.json&quot;);
              Credentials credentials = Credentials.ServiceAccountCredentialsBuilder()
                              .FromFile(Directory.GetCurrentDirectory() + &quot;/pdftools-api-credentials.json&quot;)
                              .Build();
  
              // Create an ExecutionContext using credentials and create a new operation instance.
              ExecutionContext executionContext = ExecutionContext.Create(credentials);
              CompressPDFOperation compressPDFOperation = CompressPDFOperation.CreateNew();
  
              // Set operation input from a source file.
              FileRef sourceFileRef = FileRef.CreateFromLocalFile(directory + @&quot;\&quot; + pdfname);
              compressPDFOperation.SetInput(sourceFileRef);
  
              // Execute the operation.
              FileRef result = compressPDFOperation.Execute(executionContext);
  
              // Save the result to the specified location.
              //if pdf is part of a group, the group directory name will be stored in fileGroupDirectory
              string fileGroupDirectory = directory.Replace(sourceDir, &quot;&quot;);
              
              result.SaveAs(finishedDir + fileGroupDirectory + pdfname);
  } 
  catch (ServiceApiException ex)
   {
              Console.WriteLine(&quot;Exception encountered while executing operation&quot;, ex.Message);
  
              if (ex.Message.Contains(&quot;The input file is already compressed&quot;))
              {
                 File.Move(file, finishedDir + fileGroupDirectory + fileName);                   
              }
          }
  </code></pre>