File writing problem on Windows 7 Professional in c#

Posted by Ummar on Stack Overflow See other posts from Stack Overflow or by Ummar
Published on 2010-05-24T10:49:32Z Indexed on 2010/05/24 11:11 UTC
Read the original article Hit count: 185

Filed under:
|
|
|

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
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET