surajit_shah Posted August 4, 2008 Posted August 4, 2008 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. Quote
roger_wgnr Posted August 4, 2008 Posted August 4, 2008 .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 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. Quote
Nate Bross Posted August 11, 2008 Posted August 11, 2008 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. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.