Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Moving file failed; Access is denied

Discussion in 'Editor & General Support' started by Zarincos, Mar 9, 2015.

  1. Zarincos

    Zarincos

    Joined:
    Mar 7, 2015
    Posts:
    3
    Hello everyone; I'm learning Unity and I, obviously, started with the roll-a-ball tutorial and encountered a weird glitch that wouldn't let me proceed. Basically, as far as I can tell, I tried some code that MonoDevelop liked about as much as a gunshot wound (I was just trying out some nonsense with GUIText, nothing that should have a permanent effect) and it wouldn't let me do anything with coding on that project. Specifically, whenever I tried to compile code Unity would give me this error

    Moving file failed

    Moving Temp/Assembly-CSharp.dll to Library/ScriptAssemblies/Assembly-CSharp.dll:
    Access is denied

    I deleted the offending code (it was working fine before the changes) and tried again, no luck. Restarting the computer gave me a temporary respite until it pulled its shenanigans again. I thought it might be a permissions issue but the folder has a read only attribute that not even the attrib -r command in admin mode cmd can remove.

    Long story short I upgraded to Unity 5 when it came out and started on the space shooter tutorial and nothing's going wrong. Then I try some extra-curricular activities and try to program in some stuff to delete the spawned shots when they got out of camera range. I had a number of different attempts at using the Destroy command before it pulled the exact same error message on me again. I deleted the code and tried again, this time it worked.

    Ignoring what fate was trying to tell me I did what I thought should work and tried to clean up my shots again, the error occurred, and deleting all code that isn't strictly part of the tutorial hasn't helped it and now I can't modify my shot script or player script because I always get the same error message. It should be noted that I never got the code to fully compile, so it never ran in Unity.

    Sorry if this should go into the scripts section of the forums, but it doesn't seem like it's a problem with the scripts themselves, so I figured that here was the better place. Any ideas on how to get the entire setup to start working properly again?
     
  2. Zarincos

    Zarincos

    Joined:
    Mar 7, 2015
    Posts:
    3
    As a minor update, I restarted my computer and decided to press on and try as hard as I could to simply not write any wrong line of code, since that seemed to be what triggered it before. This worked for a while until I got to a perfectly valid few lines of code, destroying the asteroid on contact with a shot, before I compiled it and went back to Unity, where I got a similar message, except that it relayed that it was successful, before immediately giving me the unsuccessful error message and subsequently rendering all my scripts temporarily useless again.
     
  3. MortePCAndVR

    MortePCAndVR

    Joined:
    Jul 21, 2013
    Posts:
    14
    Same error here, also running Unity5,
    I got my error
    "Moving Temp/Assembly-CSharp.dll to Library/ScriptAssemblies/Assembly-Csharp.dll: Access is denied"
    with only the three equally useless options to "Try Again", "Force Quit" and "Cancel".
    after restoring a backup previous copy of a project when Unity5 started pretending my first person controller had no collider and could noclip through walls.
    Will keep looking elsewhere in forums for an error, there appear to be numerous other hits but for previous Unity versions.

    Other hits recommend to disable 'Realtime protection' in antivirus, and/or whitelisting/excluding the Unity Project Folders in antivirus, will do that, reboot and see if it works.

    Nup, no luck even after reboot.
    Disabled Microsoft Security Essentials Realtime Protection AND whitelisted Unity project folder.
    Also disabled realtime malware scanner.
    Also tried setting my userid as owner for subdir branch (I am owner but still getting access denied), clearing 'read-only' checkbox for all subdirs/files (doesn't stick).

    Bit the bullet and got it working by deleting all files and subdirs in the project folder EXCEPT Assets. Unity3d rebuilt the framework by re-importing and recreating metadata, but all project settings were wiped - I reopened my scene ok however, so I'll see how I go from here.
    NOT a solution for everyone, but good enough for my test code.

    A warning to those who think restoring backups is a sure thing.

    (Found this link which also recommends this technique to only keep Assets folder and let Unity3D recreate Project files and subdirs):
    http://answers.unity3d.com/questions/966192/access-to-the-path-assembly-csharp-firstpassdllmdb.html
     
    Last edited: Jun 7, 2015
  4. TonanBora

    TonanBora

    Joined:
    Feb 4, 2013
    Posts:
    493
    Hello guys!
    Have you tried deleting, or moving the Assembly-Csharp.dll?

    ~TB
     
  5. MortePCAndVR

    MortePCAndVR

    Joined:
    Jul 21, 2013
    Posts:
    14
    Yes, I can easily move or delete Assembly-Csharp.dll and other related files outside of Unity via Windows Explorer, but that doesn't solve the problem.
    The issue is - even after deleting the entire Temp subdir under the project subdir,
    Unity3D recreates a new Temp subdir on startup/project open, then fills Temp with a bunch of files including Assembly-Csharp.dll file (presumably as some form of file cache), then attempts to write from Temp into the project's Library subdir, and THAT is when a whole bunch of 'Access Denied' errors pop up (not just the Assembly-Csharp.dll error).
    For example, today after updating an animation asset on the same restored project I thought I had cleaned completely,
    I then tried to save scene, but Unity3D blew up with THIS error (no mention of Assembly-Csharp.dll).
    cap_164.gif

    I think at this stage I am going to have to trash the entire project and start from scratch -
    Thankfully this is just a test project from the Live Training Archive (Merry Fragmas Tutorial), but I have wasted a large # of hrs on it already, so yeah...
     
    Last edited: Jun 7, 2015
  6. MortePCAndVR

    MortePCAndVR

    Joined:
    Jul 21, 2013
    Posts:
    14
    This link says to stop Unity3D, delete the Library subdir, and restart Unity3D:
    http://answers.unity3d.com/questions/55874/having-issue-starting-new-project.html

    Other links have had people running Unity3D as Administrator, disabling AntiVirus, still not working tho.

    THIS link has an interesting suggestion, i.e. disable file indexing, claiming Windows is holding file handle locks which prevents Unity from touching anything.
    http://answers.unity3d.com/questions/24571/moving-file-failed.html
     
    Last edited: Jun 7, 2015
  7. AlanMW

    AlanMW

    Joined:
    Feb 11, 2017
    Posts:
    2
  8. iwillbenice

    iwillbenice

    Joined:
    Jun 7, 2013
    Posts:
    21
    I had this problem with some .dll when importing .unitypackage. Updating plugin actually.
    My solution:
    I imported package to new project without problems. Then imported all files except that one that caused problem in my project, then manually copy it from new project.
    Problem was when overwriting that dll i suppose...
     
  9. calef

    calef

    Joined:
    Mar 9, 2015
    Posts:
    1
  10. metroidsnes

    metroidsnes

    Joined:
    Jan 5, 2014
    Posts:
    67
    In my case it was SmartGit causing this problem. Disabling it helped.
     
    5minlab_dev likes this.
  11. sam_nau

    sam_nau

    Joined:
    Oct 26, 2013
    Posts:
    9
    The cause of my file access denied issues was actually very simple: Google Drive. Even though I hadn’t told it to include my project files in the file sync, it was still including them anyway. And the very annoying fact was if a file was syncing, access to it was locked on my PC. I disconnected my Drive and all the errors went away. I’ll just have to stick with the web interface, I guess.
     
  12. DreamPower

    DreamPower

    Joined:
    Apr 2, 2017
    Posts:
    103
    I get that error when my hard drive is full
     
    Ghat-Smith likes this.
  13. ryanmillerca

    ryanmillerca

    Joined:
    Aug 12, 2012
    Posts:
    141
    Some file from that folder is likely open in another program. This will even include File Explorer / Finder windows in some cases. Close everything you can and try moving the file again.
     
  14. csumsky3

    csumsky3

    Joined:
    Jan 29, 2014
    Posts:
    13
    You are my freakin hero, this was exactly my problem.
     
  15. BootySmashDeluxe

    BootySmashDeluxe

    Joined:
    Mar 29, 2019
    Posts:
    3
    I had this problem and fixed it by moving the folder via the windows file explorer after closing my IDE.
     
  16. mikesevigny

    mikesevigny

    Joined:
    Aug 31, 2018
    Posts:
    1
    Had this same problem. Running Unity as Administrator fixed it for me.
     
    Asso2020 likes this.
  17. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    426
    Closing all windows explorer folders solved my issue.
     
  18. Abended

    Abended

    Joined:
    Oct 9, 2018
    Posts:
    142
    This was it! a windows explorer was open to my assets folder and it was stopping the specific folder move. I did 20 other folders no issue! Thanks, I would have never thought an explorer window was blocking a file copy!
     
  19. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Same. Just one folder was unable to move, despite that folder wasn't open in the Explorer. However, closing all Explorer windows did the trick.
     
  20. dpt2

    dpt2

    Joined:
    Jun 15, 2021
    Posts:
    50
    Do try/catch's work for access denied errors with this stuff? Maybe can prompt to close windows in the pre-build script.
     
  21. ryanmillerca

    ryanmillerca

    Joined:
    Aug 12, 2012
    Posts:
    141
    Hey there, just chiming in with another fix; add your entire Unity project folder to your antivirus's exception/ignore list. There seems to be more cases of antivirus interfering with Unity lately.
     
    Miguim likes this.
  22. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    113
    Deactivating anti virus worked
     
  23. uzisho

    uzisho

    Joined:
    Jul 3, 2019
    Posts:
    14
    For me - there were Unity Editor processes still active on the Windows Task Manager. Once I killed those processes it stopped throwing that error.
     
  24. steril

    steril

    Joined:
    Nov 30, 2014
    Posts:
    8
    Use Resource Monitor -> Associated Handles, search for the filename, find the process that uses it and right click, end process.
     
  25. StasonicK

    StasonicK

    Joined:
    Nov 30, 2020
    Posts:
    1
    Filename is Unity?
     
  26. sdb7

    sdb7

    Joined:
    Apr 8, 2013
    Posts:
    23
    me happen as well on unity 2020.3.1 when saving as prefab with almost 80K child object..dunno what to do and i had 32 GB free space and on win 11
     
  27. prakyath_unity

    prakyath_unity

    Joined:
    Dec 11, 2020
    Posts:
    9
    Run hub as admin
     
  28. Kerkenez

    Kerkenez

    Joined:
    Mar 13, 2016
    Posts:
    4
    Closing visual studio solved the problem for me.
     
    ruslanwas01 likes this.