Page 1 of 1
Test if a file is locked
Posted: Sat May 08, 2004 11:36 am
by Karbon
I want to test if a file is locked. Is there a quick and easy way to do that?
Posted: Sat May 08, 2004 11:59 am
by walker
Hi,
you can use this
Code: Select all
If OpenFile(1,"c:\test.txt")=0
MessageRequester("Open", "File already in use", #MB_OK|#MB_ICONERROR)
EndIf
OpenFile fails (returns 0) if the file is opened for read/write access.
cu
Posted: Sat May 08, 2004 1:13 pm
by blueznl
correct, as purebasic does not use the shared flags by default, so it wants to open the file exclusively
Posted: Sat May 08, 2004 1:31 pm
by Karbon
Well, I'm going to use copyfile() - trying to figure out under which conditions that might fail
