On Wed, Jan 07, 2004 at 01:03:28PM -0600, Rick Klinge wrote:
> I could be wrong but I always thought that it would not 'copy' over a file
> that was open or locked. I've always thought that it would copy the file if
> it was open or locked. Hmmm at least I thought it did.
A little experiment:
* Open a file and set the share mode to deny read or write, using
_fsopen("c:\\locked.txt", "w+", _SH_DENYRW);
* Wait for a key to be pressed
Meanwhile, try to copy the file with xcopy...
C:\>xcopy locked.txt backup
C:locked.txt
Sharing violation
... or copy over the file ...
C:\>xcopy test.bak locked.txt
Overwrite C:\locked.txt (Yes/No/All)? y
C:test.BAK
Sharing violation
... or see the contents with type ...
C:\>type locked.txt
The process cannot access the file because it is being used by another
process.
Next experiment:
* Create c:\locked.txt and write 'testing' to it.
* Lock only a region of a file using the Win32 API LockFile() call
* Wait for a key to be pressed
Meanwhile, try to copy the file with xcopy...
C:\>xcopy locked.txt backup
C:locked.txt
1 File(s) copied
C:\>type backup\locked.txt
testing
So the file and contents have been copied correctly. Lets try and overwrite
the file...
C:\>xcopy backup\locked.txt locked.txt
Overwrite C:\locked.txt (Yes/No/All)? y
backup\locked.txt
File creation error - The process cannot access the file because another
process has locked a portion of the file.
So far, good. Interesting, though, is that type won't work on the locked
file...
C:\>type locked.txt
The process cannot access the file because another process has locked a
portion of the file.
--
Jon Miles <[EMAIL PROTECTED]>
Cybah on IRC(net)
To Unsubscribe: http://www.ipswitch.com/support/mailing-lists.html
List Archive: http://www.mail-archive.com/imail_forum%40list.ipswitch.com/
Knowledge Base/FAQ: http://www.ipswitch.com/support/IMail/