Search code examples
asp.netiiswindows-servicesvirtual-directoryshared-directory

Can not overwrite file in virtual directory


I'm having problems with a site using a virtual directory to share images between three load balanced web servers.

The three web servers all have an asp.net website installed using IIS 7.5 and a virtual directory pointing to the same shared folder. There is no problem reading the images.

The problem is that the windows service that is downloading images and writing to the shared folder gets the exception, "The process cannot access the file 'D:\WebShare\images\440.jpg' because it is being used by another process".

Is there any way to "force" an overwrite? Or should I rethink my solution? It must be a very common scenario that multiple web servers share a folder and some other process updates the files in that folder but I can't find a solution to my problem.


Solution

  • So I've solved the problem. I have another service running on each server copying the images to a local folder instead of each server reading the images from the same shared folder.

    My guess is that the problem has something to do with the fact that an IIS website was reading from a shared folder on another server. The only difference now is that the website is reading from a local folder. I still have a windows service overwriting images in that folder.