asp.net - How can we access read and write XML at same time -


in application creating xml file every 15secs @ admin side. creating xml have used string builder xml.

file.writealltext("d:\\fe_display.xml", stringbuilder.tostring()) 

the same file used display in grid on front end every 15 secs. file minimum 10memebrs using @ same time @ front end.the below code used front end.

dim ds new dataset()    ds.readxml("d://fe_display.xml") try     if ds.tables(0).rows.count > 0         grid1.datasource = ds.tables(0)         grid1.databind()     end if catch ex exception  end try 

if both events(read , write) happens @ same time getting below error

the process cannot access file 'fe_display.xml' because being used process

use fileshare.readwrite option when opening file writing.

allows subsequent opening of file reading or writing. if flag not specified, request open file reading or writing (by process or process) fail until file closed. however, if flag specified, additional permissions might still needed access file.

take here:

http://msdn.microsoft.com/en-us/library/system.io.fileshare.aspx

example when opening:

var filestream = file.open(filename,                             filemode.open,                             fileaccess.read,                             fileshare.readwrite); 

then subsequent read of file can open without error.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -