I have a question on the Using statement in C# e.g.
using (FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Occasionally, as I loop through the near 6 million docs on a Windows server I will get an Access Denied exception
This occurs where a specific network group has not been added to the files ACL. Why this situation, which should never be the case, occurs is perplexing but I'll save that for later investigation.
When it does occur I can use XCACLS from the development PC, in a local CMD box, to add the network group to the files ACL, no problems.
My question is, while running in debug mode (VS 2005), is VS running in a different Security Principle than my account ? (Hence this exception ?)
The environment is configured like so:
Document store ----
Windows Server 2003 64bit, shared folder where the DOCS_ADMIN group has full rights at share and folder level
I'm also in another group which is a member of the Administrators on this server.
Crappy XP with VS 2005
Why I am doing this is that many users have imported 2007 Office files into the Doc Management System as Office 2003 files - and then finding that they cant read the files, since the DM app kindly renames the extension. So I have to trawl through the document store looking at the file's signature to see if it's actually an Office 2007 file. (To be fixed later)
If it is running in a different security context I may be able to code around it in the Try/Catch block.