What is the best way to read image when simultaneous requests try to access the same image file?
Basically I have created tiff viewer in asp.net. It displays thumbnails of all tiff pages and upon click loads full image below. But when I try to read big tiff file (40+ MB), some thumbnails shows up and some throw access denied error. I hope I am clear enough to explain the problem.
you should open the Stream in this way:
using (Stream s = new FileStream(fullFilePath,
FileMode.Open,
FileAccess.Read,
FileShare.ReadWrite))
{
// here use the stream s
}
in this way you open for read and still other processes will be able to read the file as well and only one process, not yours, could eventually acquire the write rights.
see here as well: How do I open an already opened file with a .net StreamReader?