On July 29th 2010 someone send me the following message:

>Have you done much with NFileStorage dealing with concurrent writes to the
>file?

For my projects I so far did concurrent reads, but no concurrent writes.

>I was looking at this as a separate backend for our file hub web services..
>but we're going to get simultaneous write requests that would go into the same
>file. When playing around with the source code I received several IO conflicts
>when attempting to re-create that environment. Maybe you have some
>thoughts on this situation.

Unfortunately there is no out-of-the-box solution in NFileStorage for preventing concurrent writes, which results in exceptions as you noticed. If you feel like sticking to NFileStorage, I do think there can be solutions to your problem, although that will impact the overall performance of your project; NFileStorage is primarily optimized for (relatively fast) reading. So no idea if the performance would be a major point (also I can't tell you how fast or slow things will be), but the solution is as follows: probably you currently use the Facade class to access the NFileStorages. If that's the case you might consider making a wrapper class yourself, which is a singleton, that simple invokes the write methods in a synchronize way. See concept below:

private class SynchronizedFacade {
private static SynchronizedFacade _singletonInstance = new SynchronizedFacade();
public static SynchronizedFacade SingletonInstance {
get
{
return _singletonInstance;
}
}

public void SyncedStoreString(string fileStorageName, Guid dataIdentifier, Encoding encoding, etc.)
{
lock(this) {
FileStorageFacade.StoreString(....pass.all.params...);
}
}
}

So, instead of storing strings using FileStorageFacade.StoreString(...), simply invoke: SynchronizedFacade.SingletonInstance.SyncedStoreString(...) and the concurrency issues should be solved.