| Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 | 1. Copyfile vs OPEN READ #13583 | I have a file I want to read - if I open it with OPEN READ I get an error message "The process cannot access the file because it is being used by another process." (fair enough, it is in use by another process).
HOWEVER.... if I copy the same file to a temp file and read that, all is well.
What I don't understand is, shouldn't the COPYFILE be reading it as well ? So, if that's correct, why doesn't that fail (or does copyfile use some different "open" that is even less intrusive than just OPEN READ) ???? | 2. #13584 | CopyFile calls a Windows OS function that does the copy. It reads the file with SHARED access, meaning that it doesn't deny anyone else from reading the file too. Of course, CopyFile fails if someone else has already denied access. The fact that CopyFile works should tell you that the other program did a SHARED open.
Stream()'s "OPEN READ" does not allow SHARED access. You're saying "I want to read the file, and prevent anyone else reading it at the same time". Of course, this fails because the other guy is already reading it. That's what the error is telling you here.
Change to Stream's "OPEN READ SHARED". (Or "OPEN BOTH SHARED"). | 3. Thanks Jeff #13585 | Not sure I'd have noticed that option even if it had been in the online help (correct me if I'm wrong, but I couldn't see it there. I could see open write shared/open both shared, but open read shared) | 4. Tried your suggestion #13586 | but it didn't work - received the same error message | Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 |
|
|