I have an application in C# which I write some data to file. I am facing the problem on windows 7 professional that when I write data to C:\ProgramData
, Access denied acception is thrown. If I login from an administrator account this issue vanishes, and if I login from some other account who have administrative previlages this issue comes up. This issue is only produces on windows 7 professional, it is working fine on all other flavors of windows 7 as well as windows vista.
try
{
XmlTextWriter myXmlTextWriter = new XmlTextWriter("Configuration.xml", null);
myXmlTextWriter.Formatting = Formatting.Indented;
myXmlTextWriter.WriteStartDocument(true);
myXmlTextWriter.WriteDocType("ApplicationConfigurations", null, null, null);
////myXmlTextWriter.WriteComment("This file represents another fragment of a book store inventory database");
myXmlTextWriter.WriteStartElement("Configuration");
myXmlTextWriter.WriteElementString("firstElement", pe.ToString());
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.WriteEndDocument();
myXmlTextWriter.Flush();
myXmlTextWriter.Close();
}catch(Exception e)
{
//Exception is thrown in Win7 professional
}