Reputation: 12544
how to lock filename , so windows users can not change File filename .
Upvotes: 1
Views: 3619
Reputation: 9
Think outside the box - use Alternative data streams.
Hide the filename you want in there & have a background task to locate ads with your data stream and restore the 'correct' file name.
Think outside the box - write your own file system and install it as an ifs
Think outside the box - don't put your data in a file, put it in a database
Think outside the box - Trust your users
This is what most of us do. Helpful error messages at start-up, graceful recovery, perhaps a file dialogue so the user can choose a filename that suits them for reasons you havn't anticipated.
Upvotes: 0
Reputation: 3214
Two ways:
Unfortunately, none of them is fail-proof... for the good of humanity :)
Upvotes: 4
Reputation: 18662
Thank God, this is not possible. You may restrict access to this file, so the user won't be able to access it and thus modify its name, but otherwise you cannot prevent them from renaming files.
One more thing, though...
If the file is continuously open in exclusive mode, nobody else will able to modify it, i.e. change its name... But this mean that some process has to lock it, i.e. windows service. Closing such service or killing the process in other way will release the lock.
Upvotes: 2