As Jared says, you cannot do this if another object that has an open file does not allow shared reads. Excel allows co-read, even for files that are open for writing. Therefore, you must open the stream with the FileShare.ReadWrite parameter.
The FileShare parameter is often misunderstood. It indicates what other file openers can do. This applies to both past and future developers. Think of the fact that FileShare is not a retroactive ban on previous openers (such as Excel), but a restriction that should not be violated with the current Open or any future Open.
In the case of the current attempt to open the file, FileShare.Read says that "open this file for me successfully only if the previous openers were read-only." If you specify FileShare.Read in a file that is open for writing in Excel, your open will fail because it will violate the restriction because Excel opens it for writing.
Since Excel has an open file for writing, you must open the file with FileShare.ReadWrite if you want your opening to be successful. Another way to think about the FileShare option: it indicates "access to the file of another guy."
Now suppose another scenario in which you open a file that is not currently open by any other application. FileShare.Read says that "future openers may open a read-only file."
Logically, these semantics make sense - FileShare.Read means that you do not want to read the file if the other guy is already writing it, and you do not want the other guy to write the file if you already read it. FileShare.ReadWrite means that you are ready to read the file, even if the other guy is writing it, and you have no problem letting the other opener write the file while reading it.
In no case does this allow several authors. FileShare is similar to the IsolationLevel database. Your desired setup here depends on the required βapprovalsβ.
Example:
using (Stream s = new FileStream(fullFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { ... }
or,
using (Stream s = System.IO.File.Open(fullFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { }
Addendum:
The documentation for System.IO.FileShare is a bit subtle. If you want direct facts, go to the documentation for the CreateFile Win32 function , which better explains the concept of FileShare.