[CLARIFIED]Is it possible to lock a file from deletion?
-
hai all, i want to know, if it is possible to lock a file, such that, nobody can delete it. why i want this is, for my application, iam using file as the database, where all the user data and other data is available. i remember that, long back, i used to lock a file from dosmode using ren command. but now iam unable to recall it. can any body remind that logic to me and also if this could be applied to solve my problem? thanks.
-
hai all, i want to know, if it is possible to lock a file, such that, nobody can delete it. why i want this is, for my application, iam using file as the database, where all the user data and other data is available. i remember that, long back, i used to lock a file from dosmode using ren command. but now iam unable to recall it. can any body remind that logic to me and also if this could be applied to solve my problem? thanks.
The C runtime provides a _lock_file[^] function. You might just want to use permissions to deny your users delete authority on the file though. Probably a safer solution.
Nothing is exactly what it seems but everything with seems can be unpicked.
-
The C runtime provides a _lock_file[^] function. You might just want to use permissions to deny your users delete authority on the file though. Probably a safer solution.
Nothing is exactly what it seems but everything with seems can be unpicked.
thanks for your response. but what i understood from msdn is, file will be locked for the other processes. what i want is, i should not be able to delete it from windows. can you just guide me.
Matthew Faithfull wrote:
You might just want to use permissions to deny your users delete authority on the file though
can you just explain me how to do it? thank you.
-
The C runtime provides a _lock_file[^] function. You might just want to use permissions to deny your users delete authority on the file though. Probably a safer solution.
Nothing is exactly what it seems but everything with seems can be unpicked.
-
thanks for your response. but what i understood from msdn is, file will be locked for the other processes. what i want is, i should not be able to delete it from windows. can you just guide me.
Matthew Faithfull wrote:
You might just want to use permissions to deny your users delete authority on the file though
can you just explain me how to do it? thank you.
In this regard Windows counts as 'another process'. I have no idea of any DOS locking tricks and I doubt they have carried over to NTFS anyway. User permission is really a sysadmin thing, you need to look at the accounts and groups of users you have on your system and talk to whoever manages it about how to secure your database against deletion.
Nothing is exactly what it seems but everything with seems can be unpicked.
-
In this regard Windows counts as 'another process'. I have no idea of any DOS locking tricks and I doubt they have carried over to NTFS anyway. User permission is really a sysadmin thing, you need to look at the accounts and groups of users you have on your system and talk to whoever manages it about how to secure your database against deletion.
Nothing is exactly what it seems but everything with seems can be unpicked.
thanks again for your explanation. now i understood that, my system administrator can do something at my clients place to achieve my task. but can you confirm that, though the folder or file is locked for deletion, still, my program can update the file? thank you.
-
thanks again for your explanation. now i understood that, my system administrator can do something at my clients place to achieve my task. but can you confirm that, though the folder or file is locked for deletion, still, my program can update the file? thank you.
Yes under modern Windows systems Delete/Create/Read/Write etc permissions are separate, you can allow or any combination to any user or group of users. You might need to specify which user your program runs as depending on the way the site is configured. A program can be launched with the permission sof a specific user and impersonates that user when it comes to getting file access. Your sysadmin could for example create a SpecialDatabaseUser user who has exclusive rights to the database itself and your program could be made to act as that user. There are lots of options and different sites may require different things but I think this approach is the most likely to succeed for deleteion prevention, 'sharing' is of course another issue altogether.:)
Nothing is exactly what it seems but everything with seems can be unpicked.
-
thanks for your response. but what i understood from msdn is, file will be locked for the other processes. what i want is, i should not be able to delete it from windows. can you just guide me.
Matthew Faithfull wrote:
You might just want to use permissions to deny your users delete authority on the file though
can you just explain me how to do it? thank you.
chandu004 wrote:
what i want is, i should not be able to delete it from windows.
I personally would be extremely annoyed by a file on my I could not delete. I would insert considerable energy in *getting* it deleted - up until formatting and reinstall, because I would immediatly suspect either a trojan or SONY and its infamous rootkits behind that. Tweaking permissions is OK, though. I *COULD* technically get the rights to delete the file, but the file has "Do not delete me!" printed in big red letters on the surface.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all.
Douglas Adams, "Dirk Gently's Holistic Detective Agency" -
Yes under modern Windows systems Delete/Create/Read/Write etc permissions are separate, you can allow or any combination to any user or group of users. You might need to specify which user your program runs as depending on the way the site is configured. A program can be launched with the permission sof a specific user and impersonates that user when it comes to getting file access. Your sysadmin could for example create a SpecialDatabaseUser user who has exclusive rights to the database itself and your program could be made to act as that user. There are lots of options and different sites may require different things but I think this approach is the most likely to succeed for deleteion prevention, 'sharing' is of course another issue altogether.:)
Nothing is exactly what it seems but everything with seems can be unpicked.