Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blocking a folder with contents for all other apps

Status
Not open for further replies.

firelex

Programmer
Jan 10, 2002
118
0
0
DE
Hello, all!
The problem is in the subj:
I have a folder with some subfolders and many files.
I need to block this folder from reading/writing of any files by all other apps.
And at the start of my prog I need to know if any of the files is already opened by another app.
 
If your filesystem is NTFS, you can restrict access to certain files for certain users.

What about aplications... - may be open all the files using CreateFile() with no sharing - dwShareMode=0 or simply fopen() :). You should get negative responce in case if the file is allready open.
 
I've thoght about opening all the files and hold them for the whole time of my prog working. But it isn't so comfortable. I don't know how many of those files I'll find.

And the second: I've tried the following:
I've opened a file with the windows editor and then started this code
Code:
        CFile file;
        if (!file.Open(path, CFile::modeWrite)) {
            error = TRUE;
        } else {
            file.Write("123", 3); 
        }
        file.Close();

it all worked fine!!!!!!! Editor didn't show anything, but after I re-opened the file it had at the beginning "123"!!!!
 
> Editor didn't show anything, but after I re-opened the file it had at the beginning "123"

You are right, it seems, that, for example, notepad closes input file after reading it to the buffer. But if the file is meanwhile opened by another application, it could not be saved from notepad, until that application closes it.
 
In any way I need to block all the files in the directory from writing, or at least to check, if any of them are opened by another app.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top