Question

I am trying to open a file (included in my project as Content and Copy Always options) using a FileStream. I am getting the following error:

***Access to the path 'E:\approot\PdataParsingRules.xml is denied.***

I am using the below code to get the path of my file:

Path.Combine(Environment.GetEnvironmentVariable("RoleRoot") + @"\", @"approot\PdataParsingRules.xml");

And I am using the below code to de serialize my file:

ParsingRules rules;
XmlSerializer serializer = new XmlSerializer(typeof(ParsingRules));
fileStream = new FileStream(rulePath, FileMode.Open);
rules = (ParsingRules)serializer.Deserialize(fileStream);
return rules;

When I do an RDC to one of my worker role instances (running in full trust mode), I see that this particular file has Read, Read & Execute rights for regular users in that VM. Admin and System have full control on the file. My de serialization works fine if I manually give full rights to regular users but that doesn't solve the problem for obvious reasons.

Any ideas on this would be greatly appreciated.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top