Preventing a file from deletion and change


<br /> I have a text file. I need to the following:<br /> 1. Prevent remove a file.<br /> 2. Prevent changes to the file.<br /> Even if the program is not running. Is this possible? Maybe through the use of the service?<br /> Users of application can add new data to a file.

General: I need to prevent my file from delete and any changes (outside of my app).<br /> Thanks.


This would be something you do with file permissions. Inside of the files security settings, you can set who can delete the file, who can modify the file, etc. You could have the application elevate its rights to be able to modify the file.

If the application is not running, it cannot protect the file itself. Running the application as a service would allow it to stay running, which would allow it to perform some protective actions on the file but you would need a second application to interact with the user then and you would also be doing the job of the operating system. Elevating rights inside of the C# application is much easier than attempting to do what you are doing through code.


You can use Windows RBS to ensure that the file can only be modified or deleted by Administrators and a specific system user which your program creates and can be run in that context.

NEVER block Administrators' access to files; you will catch seven levels of hell from your application's users, who can't remove this one file (and thus can't remove the installation folder) when uninstalling your app.


  • How to prompt user that edits have been made upon changing pages or sorting in Kendo Grid
  • How to upload files in php using html
  • How to distribute an event to all nodes in a (Wildfly) cluster?
  • Granting permissions to Azure Active Directory Web Application automatically
  • IE6 changes DOCTYPE to a bad one
  • HttpListener.IsSupported is false on XP SP3
  • Enabling DTD support in Sql Server
  • GAE: Way to get reference to an HttpSession from its ID?
  • Does Mobilefirst provide a provision to access web services directly?
  • Unable to get column index with table.getColumn method using custom table Model
  • Visual Studio 2010 debugger build correctly - compiler pdb and linker pdb not in synch?
  • How to get Eclipse Oxygen to run on Java 9
  • Transactional Create with Validation in ServiceStack Redis Client
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • Hardware Accelerated Image Scaling in windows using C++
  • MailKit: The IMAP server replied to the 'EXAMINE' command with a 'BAD' response
  • Android full screen on only one activity?
  • Adding a button at the bottom of a table view
  • Is calc() supported in html email?
  • Getting last autonumber in access
  • req.body is undefined - nodejs
  • Symfony2: How to get request parameter
  • ActionScript 2 vs ActionScript 3 performance
  • How can I estimate amount of memory left with calling System.gc()?
  • Delete MySQLi record without showing the id in the URL
  • Apache 2.4 - remove | delete | uninstall
  • Akka Routing: Reply's send to router ends up as dead letters
  • GridView Sorting works once only
  • XCode can't find symbols for a specific iOS library/framework project
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • How do I rollback to a specific git commit
  • Is there a mandatory requirement to switch app.yaml?
  • Suggestions to manage Login/Logout transitions
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Busy indicator not showing up in wpf window [duplicate]
  • reshape alternating columns in less time and using less memory