Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have to either a) stop the process which is using the file or b) wait until the file isn't being used anymore.</p> <p>You should read this wikipedia entry on <a href="http://en.wikipedia.org/wiki/File_locking" rel="nofollow noreferrer">File Locking</a>. Pay particular attention to the "In Microsoft Windows" paragraph where you will get a better idea about how file locking works.</p> <p>If another program has opened the file with the <em>sharing mode</em> parameter stating that the file will <em>not</em> be shared even for read-access, then there is nothing you can really do to <em>force</em> the copying operation from <em>your</em> application.</p> <p>If you are keen to "play god", and you are willing kill processes that may be holding a lock on the files you are concerned with, then you can attempt to find out which process is holding on to your file using the information in this thread: <a href="https://stackoverflow.com/questions/317071/how-do-i-find-out-which-process-is-locking-a-file-using-net">How do I find out which process is locking a file using .NET?</a></p> <p>A better strategy is probably to investigate <em>why</em> the file that your are copying is being locked, and whether it is possible to avoid the lock conflict, by setting restrictive file permissions on the file(s), or by reconfiguring the software which is competing for the lock on the file. E.g. If an antivirus program occasionally scans a folder structure used by your app, then you can perhaps tell the software to ignore that particular folder. </p> <p>If execution time is not critical you can perhaps delay or postpone your copy operation. A simple strategy would be to get-that-locked-file-on-the-next-iteration-instead. Another strategy could involve listening for events e.g. from the <code>FileSystemWatcher</code> class, with the idea to <a href="https://stackoverflow.com/questions/50744/wait-until-file-is-unlocked-in-net">Wait until file is unlocked in .NET</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload