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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

prevent deletion of files

Status
Not open for further replies.

earlrainer

Programmer
Mar 1, 2002
170
IN
Hi ,

is there a way in delphi/windows where i can prevent the users from deleting the text files i make.

I need to read from these files..so i cant hide these files.

Or is this simply not possible

Bye
 
earlrainer,

Well, you can set the file's read-only attribute using something like this:

Code:
procedure TForm1.Button1Click(Sender: TObject);
const
   k_FILENAME = 'c:\xyzzy.txt';
begin

   memo1.lines.saveToFile( k_FILENAME );
   fileSetAttr( k_FILENAME, faReadOnly );

end;

But, that's really not a good solution as Windows makes it pretty easy to delete these. It's really only good for making sure that user's do want to delete that file, as Windows Explorer provides a prompt.

Now, if you're storing these files on a network server, it's possible your network operating system will allow you to restrict delete priveleges on the file(s) in question. You'll need to work with your network admin for help with that.

You might also be able to restrict deletes through your Manage Users command.

Hope this helps...

-- Lance

 
Earlrainer from my early dos days in pascal I remember that hiding a file, doesn't restrict you from reading or writing to it. You only have to know the name and place, in fact I made a sort of copy protection for a program, by looking if a hidden "authorization" file was available. If you copied (illegally) the program without the file, it showed a telephone number.

Of course this will help if the user do not use "show hidden files" in the explorer. S. van Els
SAvanEls@cq-link.sr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top