Return to Technical Information Index

Cannot delete sharing violation source destination file
[This is basically the original post on this problem, with some minor wording adjstments - when I wrote this, I didn't know what the cause of the problem was. Now that I understand it, I updated the post, which is available here:  Sharing Violation Solutions  ]
This typically happens a folder is 'Moved' from one location to another - the folder get's created in the new location and the files usually get moved - The error occurs when the 'Move' command tries to delete original location folder - and I end up with an empty folder - Renaming a folder can also suffer from the same error - most annoying 
Trying to delete a file that is open in another window will cause the same error, but all I need to do here is close the other window and I can delete the file - 
And it happens when files from deleted from the temporary files folder - most of the files will be deleted and only a few will 'resist', which the are the most currently created files - at least this one is understandable, the system 'thinks' it needs those files -  
Most of the time, one of the following actions will work - the first two are drastic measures and usually work - the other solutions are less drastic, but none of them will work all the time - I am still looking for a less drastic solution that works reliably -  
Reboot the computer 
Rebooting will usually allow the deletion, but is time consuming - I think this is one of the major reasons why installs and un-installs reboot your computer, to delete various items the system won't let the install/un-install program to delete -  
  • <Ctrl><Alt><Delete>  
  • Click on shutdown 
    Start and restart explorer.exe in the Task Mgr 
    Trouble with stopping and starting Explorer.exe is that you lose most of the systray and taskbar icons - 
  • <Ctrl><Alt><Delete>  
  • Click on Task Manager 
  • Click on the Processes tab 
  • Click the "Image Name' column heading to sort the list by name 
  • Scroll down through the list and click on explorer.exe to highlight it 
  • Click 'End Process' button 
    Gate will come down, lights flash, bells will ring, but explorer will automatically restart and you will get your window's shell back, although you will lose most of your systray icons -  
  • Click the X close button on the Task Manager window  
    Launch folder windows in a separate process 
    Here's a 'trick' that seems to work most of the time and has some good side effects - your system may run a little better and quicker - if one window has an error and crashes, it should not affect any other windows and the instance of explorer shell that is supporting windows won't be affected by the crash - the downside is that it may take a bit more memory to run the additional process -  
  • Open Windows Explorer on drive c 
  • click on Tools -  
  • Folder Options -  
  • View 
  • check "Launch folder windows in separate process" 
    Now when you are unable to delete a folder, close any and all open Folder windows. Open a new Folder window and try to delete again. This is a nuissance, but better than re-booting. Unfortunately, it doesn't always work 
    Just to be clear, one instance of explorer.exe is always running and provides the Window's shell functions - when launch folder windows in a separate process is enabled, the file manager function is provided by one additional instance of explorer.exe which is started when a folder window is opened - that one additional instance provides file manager support for all subsequently opened folder windows - another instance of explorer.exe is not started for each new folder window which is opened - 
    You must close all open windows and that additional instance of explorer.exe will stop, leaving the one instance of explorer.exe running which is supporting the Window's shell functions -  
    Or you may close the additional instance of explorer.exe with the task manager, which will close all open folder windows -  
    When you open an new folder window, a new instance of explorer.exe is started, hopefully sans the Open File Handle and may allow deletion of the troublesome folder/file -  
    Also some say (MS is one) that the additional process may take more memory, but I don't think this is true - when explorer.exe thinks it has to support both the windows shell and file manager functions, it can take up to 8 Meg, just in case - when explorer.exe is run just for the windows shell, it's memory consumption is much less - and the additional explorer.exe to run the file manger only grabs what it needs, so the memory for both explorer.exe processes may actually be less than using one - plus two process are more stable and generally faster -  
    Use another program 
    I use ACDSee's picture browser - it is geared towards managing images and has a typical folders explorer bar - I have to be careful, because it will show a folder as empty if it doesn't have any pictures in it (I have it configured that way) - but just for grins, when I have one of these pesky empty folders that explorer.exe won't let me delete, I have started that program up and it will be 'allowed' to delete the folder - 
    Try Distracting WIndows  
    If you must rename the folder then simply load another dummy bmp file from a temp directory eg c:\temp\temp.bmp just after loading the test bmp 
    Win 2000 locks the last resource opened of that type which in this case is the test.bmp is still open. 
    eg select any avi file from explorer, you will get a preview window. now try renaming or deleting that file from the same window, you will get the same error message. If you then select another file of the same type i.e. avi then you will be able to delete the first file if you select it quickly and press delete key before the preview appears  
    Hope this helps 
    Try Logging On As Another User 
    My system is set not to require a logon, all users logon with same user name - so far I have been reluctant to change the logon method and therefor have not experimented with this approach -