Could not get write access, so trying read-only

Hi All,
I am in the process of upgrading my C6 application to C10 in small batches. There were few issues that I have come across, but has been addressed. This particular one is giving me some tough time.

I have few automated processes that run in the sys tray. Occasionally, and very randomly one of these app would show an error “Could not get write access to , so trying read-only”. I do understand what this error means. But, why is this happening, when I only open the file in the share mode. All the files are opened using the FileManager’s code as follows:


! Start of my code
! My code goes here
! End of my code


I use Clarion10 and Topscan.
The code set has remain unchanged from C6.

Thanks you


Hi Mathew,

Just guess that “share mode” here is the File Control Flags setting, where user access is Read/Write and other access is DenyNone. As you can see, you’re trying access the file with Read/Write. So you can check, maybe the file has ReadOnly attribute.

Hope this helps.
Khanh Nguyen

Thanks Khanh,
The problem is very random. The file is not read-only. First of all, it happens to random files. Again, these files are simultaneously used by separate processes (background processes as well as on the UIs too).

Sometimes, one of the processes would show this message. This message pops up after Access:File.Open() call. If I OK through the message, it would continue to work fine for days. Then, may be get a similar error for another file.

So, depending on your usage, you can try to open the file with ReadOnly mode as well. If there’re multi-processes work with the file at the same time, you may think about catching the error and log them. Just my opinion. :neutral_face:

Clarion will check for locked files and retry, so as to allow for momentary conflicts with other programs or threads. But if the lock persists it will show that error and try just opening “for read”.

Check other programs using the files, and how long they might be holding them locked. Also check permissions.

However, I have seen some indications that recent Windows 10 changes might be interfering with the retries, in some way. Not sure yet, though.

that could perhaps be your answer - ie. maybe you are looking at the file in Topscan at the time

just a guess but something to check next time it happens