.NET Framework Bookmark and Share   
 index > 64-Bit .NET Framework Development > Access to the path "c:\ab\cd\file.xml" is denied
 

Access to the path "c:\ab\cd\file.xml" is denied

Hello all,

I am using XmlTextWriter to write some config info into an xml file. It was working fine until some min ago. But, all a sudden, am receiving
"Access to the path 'C:\ab\cd\file.xml' is denied."

XmlTextWriter

tw = new XmlTextWriter(@"c:\ab\cd\file.xml", System.Text.Encoding.Unicode); // this is the line of statement that is returning an error message.

The stack trace looks like:

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.Xml.XmlTextWriter..ctor(String filename, Encoding encoding)
at StoryCatch.UserChooser.SaveUserInfo() in C:\ab\cd\ef\gh\Source\MKChooser.cs:line 139

I manually checked that i have full previledge to the file. Please help its so urgent.

Thanks,
Zolyit.

zolyita

I reboot the system, re-opened vs 2008 and tried it. Still there was a problem. Finally, don't know who but the file i was attempting to read is set to READ ONLY. So unckecking it makes everything smooth. I know my application didn't change any file attributes and am wondering how it changes to RESD ONLY.

Thanks alot nobugz!
zolyit

zolyita
One scenario is that you've deleted the "cd" directory but it couldn't yet be deleted because it was locked by another app. Any attempt to do something with that directory generates Access Denied. Reboot to fix.
Hans Passant.
nobugz

I reboot the system, re-opened vs 2008 and tried it. Still there was a problem. Finally, don't know who but the file i was attempting to read is set to READ ONLY. So unckecking it makes everything smooth. I know my application didn't change any file attributes and am wondering how it changes to RESD ONLY.

Thanks alot nobugz!
zolyit

zolyita

You can use google to search for other answers

Custom Search

More Threads

• How do you install OWC on Vista 64?
• x64 COM registering error
• how to build X64-bit lib
• C# + VS2005 + SmtpClient not working on Win 64 2k3
• .NET Framework 2.0 won't install
• Itanium compiler error
• System.AccessViolationException in System.Collections.Generic.List`1.Enumerator.MoveNext() in IIS6
• can't build 64 bit after installing 2005 beta
• machine.config validation key problem
• Conexant high definition audio