CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 1999
    Posts
    492

    Protecting a folder from being deleted

    I have an application that depends upon a folder existing on the system and I want to prevent the user from being able to delete it. The only way I can think of is to create a dummy file within the folder and keep an active file handle open upon it. This is fine, but I was wondering if there was a more elegant and/or established way of doing this.

    My application is activated when the system starts and ends when the system shuts down.
    Why are the "tolerant" so easy to offend?

  2. #2
    Join Date
    May 2005
    Posts
    4,954

    Re: Protecting a folder from being deleted

    What do you by "depends upon a folder existing" ? Just the existence? Or it depends on the data you have in the folder?


    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  3. #3
    Join Date
    May 2007
    Posts
    811

    Re: Protecting a folder from being deleted

    What about using permission on folder to disable deleting it?

  4. #4
    Join Date
    Nov 2007
    Posts
    129

    Smile Re: Protecting a folder from being deleted

    I believe deleting is the same as writing, so disabling write permission should disable deleting.

    Look up the SetFileSecurity() function.
    This should do the trick.

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