How to Protect XML file

surajit_shah

Newcomer
Joined
Jul 28, 2008
Messages
5
I have a windows application in C#.net.In my application there is a xml file which is updated on every 30 seconds by the application automatically.I don't want the external user to update or tamper the xml file.So how can I Protect the xml file so that other users can not read or update the xml file.


Help me.

Thanks in advance.
 
.So how can I Protect the xml file so that other users can not read or update the xml file..
To prevent other users from accessing the file when you open the file set the FileShare mode to None. Since you did not post any code I am not sure what method you are using to open and update the file. A sample using the would be
Visual Basic:
File.Open("C:\temp\Filename.xml",FileMode.Append,FileAccess.ReadWrite,FileShare.None);
the FileShare can be None which will cause all access by other programs to fail until it is released. You can also set it to Read to allow read only access.
 
Out of curiosity, why do you need to update an XML file every 30 seconds? Do other programs read this XML file, or is it only for use by your application?

I'm just wondering if there might be a better way to achieve your desired result? Even if it's a small file, disk IO every 30 seconds could start to impact system performance.
 
Back
Top