したがって、私のプログラムでは、COM Automation (Silverlight 4 の AutomationFactory) を使用して FileSystemObject を作成し、そこに文字列 (theContent) を書き込みます。この場合の theContent は小さな UTF-8 XML ファイルであり、これを MemoryStream を使用して文字列にシリアライズしました。
文字列は問題ありませんが、何らかの理由で FileSystemObject の Write メソッドを呼び出すたびに、「HRESULT 0x800A0005 (CTL_E_ILLEGALFUNCTIONCALL from google)」というエラーが表示されます。最も奇妙な点は、"hello" のような別の単純な文字列を渡すと、問題なく動作することです。
何か案は?
または、直接シリアル化できる FileSystemObject を使用してファイル/テキスト ストリームを公開する方法があれば、それも良いでしょう (VB 以外には何も見つからないようです)。
前もって感謝します!
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();
}