You're right, the error message (File doesn't exist) depends on the application.
In fact :
- when I open "Z:\Example.txt" the error is "File doesn't exist. Create it?";
- when I open "Z:\Example.pdf" the error is "There was an error opening this document. Access denied";
- when I open "Z:\Example.docx" the error is "Word cannot open the document : user does not have access privileges".

I want to simulate the behavior of windows RecycleBin in a folder contained in my virtual storage.

In this folder I was able to prevent the creation of new files (using Access Denied) and now I want to prevent to open existing file in this special folder and show, if possible, a message like the prevent of creation (Access Denied Error).

But, if I reply the posted code in OnOpenFile event it didnt't works, because in this case error are manage by single application and in fact all files are opened even if I throw an ECBFSError.

I think that either you describe not what you have or don't exactly follow what happens.

You have stated that attempt to open the file in different applications has lead to the error message. The file is not opened after this error message. I don't see any problems in the described behaviors - it corresponds to how the things should work.

Ok, finally we've moved further :). If the OS knows that the file exists (you have returned file name when directory was enumerated), it has no chance to know that there's no access allowed to the file for some particular application. So it starts the application and the application attempts to open the file. This is normal OS logic and I have yet to see anything different.

In other words, it's not the OS that initiates opening the file and after that runs an application, but the application is started first, and then *it* attempts to open the file.

To disable edit file function I can modify OnSetFileAttributes : when user delete a file this is moved in RecycleBin folder and its attribute changed to read-only mode. After that when user try to edit file attributes OnSetFileAttributes prevent to disable read-only mode fot these files.

Davide Baccaglini wrote:
Ok Eugene, now I know that I can't disable to open file =)

This is an incorrect statement. The file is not opened in your case.

Quote

Davide Baccaglini wrote:
To disable edit file function I can modify OnSetFileAttributes : when user delete a file this is moved in RecycleBin folder and its attribute changed to read-only mode. After that when user try to edit file attributes OnSetFileAttributes prevent to disable read-only mode fot these files.

It's right?

No. Read-only attribute is a leftover of old DOS times and even then it was purely informative and didn't restrict anything. To prevent file edit operations you need to cancel Create and Open_for_writing operations.

We use cookies to help provide you with the best possible online experience. By using this site, you agree that we may store and access cookies on your device. You can find out more about and set your own preferences here.