Properly saving XDocument
<p>I have a custom data service in my website , which is supposed to refresh data every 10 minutes without any downtime for users. ( asp.net mvc3 , mssql 2008 , c# )</p>

<p>At the moment it's refreshing data every 10 minutes and updating my database ( mssql ) no problem. But the thing is ,  instead of reading data off db for every user request , I want to save it to a XML file right after refreshing data so users can get it without any extra db connection or process.</p>

<p>So there will be one process regathering data and writing to XML meanwhile lots of user will be requesting that XML every second.</p>

<p>Since I don't know much about File Write/Read stuff , I'm not sure if I should lock file before writing it , because other processes may be reading it. Or maybe it's OK since just one process will be writing and others reading/requesting it won't create any problems? Also not sure if the Save function of XDocument already has lock before writing in it.</p>

<p>So , all in all ; how can i safely save my XDocument objet into a xml file while any other processes may be reading/requesting that file?</p>

<p>OR should I just read data from Sql ( nevermind the process time&amp;delay for every user) and return XDocument object , which would be easier I guess?</p>

<p>Thanks in advance!</p>
