わかりましたので、次のようにしてファイルをメモリにキャッシュしています
byte[] file = System.IO.File.ReadAllBytes("test.xml");
その後、次のようにそのバッファから xml ドキュメントを作成しようとしています。
System.IO.MemoryStream stream = new System.IO.MemoryStream(file);
System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(stream);
System.Xml.Linq.XDocument xPartDocument = new System.Xml.Linq.XDocument(reader);
ただし、これは次の例外を除いてドキュメントの作成に失敗します:
A first chance exception of type 'System.ArgumentException' occurred in System.Xml.Linq.dll Additional information: Non white space characters cannot be added to content.
ただし、「リーダー」は間違っているように見えます。つまり、ローカルでは値として「なし」になっています。
- リーダー {なし} System.Xml.XmlTextReader
また、「ファイル」バイト配列変数には、ヘッダーのように見えるものが 11 バイトあります (これは単なる txt ファイル ヘッダーだと思いますか?)。
0x0393B148 58 35 59 71 X5Yq
0x0393B14C dc 67 01 00 Üg..
0x0393B150 ef bb bf 3c <
0x0393B154 3f 78 6d 6c ?xml
0x0393B158 20 76 65 72 ver
どんな助けでも大歓迎です。
ありがとう