So in my program I'm using COM Auotmation (AutomationFactory in Silverlight 4) to create a FileSystemObject, to which I write a string (theContent). theContent in this case is a small UTF-8 XML file, which I serialized using MemoryStream into the string.
The string is fine, but for some reason whenever I call the FileSystemObject's Write method I get the error "HRESULT 0x800A0005 (CTL_E_ILLEGALFUNCTIONCALL from google)." The strangest part is that if I pass another simple string, like "hello," it works with no problems.
Any ideas?
Alternatively, if there's a way to expose a file/text stream with FileSystemObject that I could serialize to directly, that would be good as well (I can't seem to find anything not in VB).
Thanks in advance!
string theContent = System.Text.Encoding.UTF8.GetString(content, 0, content.Length);
string hello = "hello";
using (dynamic fsoCom = AutomationFactory.CreateObject("Scripting.FileSystemObject"))
{
dynamic file = fsoCom.CreateTextFile("file.xml", true);
file.Write(theContent);
file.Write(hello);
file.Close();
}