Link to home
Start Free TrialLog in
Avatar of rwallacej
rwallacej

asked on

Protecting file / multi read and write C# / VB.Net

Hi
Here's my scenario.

1) there is a small file in app_data say "MyFile.xml" for use in users session
2) this file is read and contents filtered/put into dictionary in each users session (to avoid multi-read for such small data) when they visit page Startup.aspx

3) this file can be changed by any user on a different page, say Config.aspx

I guess I need to use threads to prevent Read/Write conflicts between users reading file when visiting Startup.aspx and a user writing on Config.aspx, and 2 or more users trying to change/read file at same time?

if so how - is reasoning right?

Thanks
Avatar of sognoct
sognoct
Flag of Italy image

Why don't you put the data in a sql table ? It will solve easily all kind of conflicts.

For using xml file in read only mode there are no issues.
But, as you correctly said, if 2 users want to modifify the data you have to use file lock mechanism, to prevent concurrent write, which is sometimes faulty on NTFS.
ASKER CERTIFIED SOLUTION
Avatar of Michael Fowler
Michael Fowler
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rwallacej
rwallacej

ASKER

Thanks.

Database is not option unfortunately - I did wonder about using this but the (small) data amount has to be easily shared amongst different PCs not necessarily running database via e.g. email and XML file was used as option
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
great thanks