title: Can't update Android Studio - Access Denied and java.io.FileNotFoundException
body: <p>I'm trying to update Android Studio from 0.5.1 to 0.5.2 on two separate Windows machines, one with Windows 7 Pro 64-bit and one with Windows 7 Enterprise 64-bit.</p>
  
  <p>I get the normal update prompt:</p>
  
  <p><img src="https://i.stack.imgur.com/sMlod.png" alt="enter image description here"></p>
  
  <p>...and if I choose "Update and Restart", the patch downloads and the IDE exits, but then I get the following dialog:</p>
  
  <p><img src="https://i.stack.imgur.com/YQFoT.png" alt="enter image description here"></p>
  
  <p>I can't change any of the "Solution" column entries.  If I click "Proceed", I get the following message as shown below (image and text, so its copy/paste/search-friendly):</p>
  
  <p><img src="https://i.stack.imgur.com/XkEYC.png" alt="enter image description here"></p>
  
  <pre><code>Temp. directory: C:\Users\Sean\AppData\Local\Temp\
  
  java.io.FileNotFoundException: C:\Program Files (x86)\Android\android-studio\lib\jsch.agentproxy.usocket-nc.jar (Access is denied)
  at java.io.FileOutputStream.open(Native Method)
  at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:221)
  at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:171)
  at com.intellij.updater.Utils.copyStreamToFile(Utils.java:135)
  at com.intellij.updater.CreateAction.doApply(CreateAction.java:52)
  at com.intellij.updater.PatchAction.apply(PatchAction.java:140)
  at com.intellij.updater.Patch$3.forEach(Patch.java:198)
  at com.intellij.updater.Patch.forEach(Patch.java:248)
  at com.intellij.updater.Patch.apply(Patch.java:194)
  at com.intellij.updater.PatchFileCreator.apply(PatchFileCreator.java:86)
  at com.intellij.updater.PatchFileCreator.apply(PatchFileCreator.java:77)
  at com.intellij.updater.Runner.doInstallImpl(Runner.java:307)
  at com.intellij.updater.Runner.doInstall(Runner.java:268)
  at com.intellij.updater.Runner.access$000(Runner.java:18)
  at com.intellij.updater.Runner$2.execute(Runner.java:258)
  at com.intellij.updater.SwingUpdaterUI$7.run(SwingUpdaterUI.java:230)
  at java.lang.Thread.run(Thread.java:744)
  </code></pre>
  
  <p>When I click "Exit", Android Studio re-opens, and tells me that the update is still available.</p>
  
  <p>I've updated Android Studio previously using this same method on both machines without a problem.</p>
  
  <p>Since I believe this is some kind of bug with Android Studio specific to newer releases, I've opened <a href="https://code.google.com/p/android/issues/detail?id=67794" rel="noreferrer">Issue 67794</a> on the AOSP issue tracker.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I was able to update from 0.5.2 to 0.5.3 today on both machines without encountering this issue.  I was shown the Windows security prompt for the JetBrains installer as in previous successful updates, and update completed successfully without me having to start Android Studio with elevated permissions.  So, seems the problem was something specific to 0.5.1 or 0.5.2 patches.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I encountered a similar error when trying to update from Android Studio 0.6.0 to 0.6.1:</p>
  
  <blockquote>
    <p>Temp. directory: C:\Users\barbeau\AppData\Local\Temp\</p>
    
    <p>+----------------
    A file operation failed.
    This might be due to a file being locked by another
    application. Please try closing any application
    that uses the files being updated then press 'Retry'.
    +----------------</p>
    
    <p>com.intellij.updater.RetryException: Cannot delete file C:\Program Files (x86)\Android\android-studio1\lib\openapi.jar
        at com.intellij.updater.BaseUpdateAction.replaceUpdated(BaseUpdateAction.java:40)
        at com.intellij.updater.UpdateZipAction.doApply(UpdateZipAction.java:199)
        at com.intellij.updater.PatchAction.apply(PatchAction.java:140)
        at com.intellij.updater.Patch$3.forEach(Patch.java:198)
        at com.intellij.updater.Patch.forEach(Patch.java:248)
        at com.intellij.updater.Patch.apply(Patch.java:194)
        at com.intellij.updater.PatchFileCreator.apply(PatchFileCreator.java:86)
        at com.intellij.updater.PatchFileCreator.apply(PatchFileCreator.java:77)
        at com.intellij.updater.Runner.doInstallImpl(Runner.java:307)
        at com.intellij.updater.Runner.doInstall(Runner.java:268)
        at com.intellij.updater.Runner.access$000(Runner.java:18)
        at com.intellij.updater.Runner$2.execute(Runner.java:258)
        at com.intellij.updater.SwingUpdaterUI$7.run(SwingUpdaterUI.java:230)
        at java.lang.Thread.run(Thread.java:745)</p>
  </blockquote>
  
  <p>This seems to happen if you try to run the update while the Gradle build process is still running (e.g., right after you start up Android Studio).</p>