CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Guest

    Make a file that can not be deleted

    Is it possible to change a file so that the user cannot delete using normal delete command?


  2. #2
    Join Date
    May 1999
    Location
    Houston
    Posts
    21

    Re: Make a file that can not be deleted

    Use SetFileAttributes(...) API. Uset GetFleAttributes first to get the attributes, and then OR the attributes with FILE_ATTRIBUTE_READONLY attribute. Then use SetFileAttributes(...). You can also make a file a system file or hide it with the same API.

    Hope this helps.

    Vali





  3. #3
    Guest

    Re: Make a file that can not be deleted

    setting the systemfile and hidden attribute won't stop the user from delitng the file if he/she really tries to delete the thing
    Don't know if you are running NT or not
    if you are running NT try to alter the security descriptor of the file so that only a certain type of user can delete it.



  4. #4
    Join Date
    May 1999
    Posts
    156

    Re: Make a file that can not be deleted

    Please give some coding samples to stop user deleting file in NT.

    Thank you.




  5. #5
    Join Date
    May 1999
    Location
    Greenville, SC, USA
    Posts
    33

    Re: Make a file that can not be deleted

    There is a really interesting trick in DOS where you make a file start with the ascii character 0255, by holding down alt and typing 0255. The command would look like this:
    rename original.cpp <alt+0225 here>original.cpp
    When windows sees this file, in say explorer(it will look like _original.cpp), but attempting to delete it is basically impossible. The only problem I see is that it may also be difficult for your program, which also runs in windows, to access this filel. I don't know, but I hope this helps.
    The only way to delete said file is throgh DOS again. If you have any questions about this or DOS, feel free to email me or reply to this post.
    ~G²


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured