tags:

views:

20

answers:

1

I need to write string to an xml file in Silverlight. When I used the following code, the above mentioned exception "Attempt to access the method failed: System.IO.StreamWriter..ctor(System.String, Boolean)" has occurred.

using (StreamWriter sw = new StreamWriter("C:\Test.xml", false)) { sw.Write(root.ToString()); }

Can anyone help me out in doing writing to xml file in Silverlight?

Thanks & Regards Padma

+1  A: 

Silverlight is in a sandboxed mode where it has restricted access. You can write to "Isolated Storage", but you cannot create files on their hard drive.

http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile(VS.95).aspx

http://forums.silverlight.net/forums/p/22011/77243.aspx

JustLoren