An internal application in our company requires files aa, bb ... zz in folder X to be read upon startup. When I (as someone with FullControl access to folder X) launch the app, all goes fine. When any of my colleagues (who only have Read access to folder X) launch the app, they get an "Access denied to file aa ... " exception.
The files are being read by the following routine
public static void readFromBinaryFile(this QIHasFileIo xThis, string xFilePath)
{
if (!System.IO.File.Exists(xFilePath))
throw new System.Exception("File to read " + xFilePath + " does not exist ... ");
if (xThis == null)
throw new NullReferenceException("xThis cannot be null, as it is a readonly reference ... ");
using (BinaryReader xReader = new BinaryReader(new FileStream(xFilePath, FileMode.Open, FileAccess.Read)))
xThis.readObject(xReader);
}
i.e. I am specifying the Read mode, which should in turn require only Read access to the folder. When my colleagues go to folder X in Explorer, then can copy the aa, bb, ... files to their Desktops, which means they DO have Read access to the files.
So I am intrigued. This weird behaviour started with changes to the data server a couple days ago. The most notable changes were that 1/ my colleagues stopped having admin rights on the data server 2/ some GPO's might have been messed up (it happenned before in the company). The IT department is baffled as well, so I have no clue how to proceed.
Any hint is much appreciated, Daniel
Edit: An already deleted post proposed using FileShare.ReadWrite
. I am grateful to the author for the comment, however the file is guaranteed not to have a write-lock on it. Hence, the why File.copy works but File.OpenRead prompts access denied? thread is not relevant here.