I would suspect the you're not handling NetworkStream correctly, so
DataSet.ReadXml() could not read any data.
The best way to go is to figure out how to get file (any file) from PC to
the device intact and add DataSet code as soon as it works.
If I understand correctly, you're using sockets to get your file, right?
You do have other options besides that. You can:
1. Puts a file on PC's shared folder and load it.
2. Publish file on a web server and get file's content using WebRequest.
3. Use Active Sync to transfer the file to the device.
As to memory stream, this should do it:
DataSet ds = new DataSet();
ds.ReadXml( "FileNameHere" );
MemoryStream ms = new MemoryStream();
ds.WriteXml (new XmlTextWriter(ms, Encoding.UTF8),
XmlWriteMode.WriteSchema);
ms.Seek( 0, SeekOrigin.Begin );
DataSet ds1 = new DataSet();
ds1.ReadXml ( new XmlTextReader(ms));
Best regards,
Ilya
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Thread-Topic: Transferring a Dataset
thread-index: AcQjDg/WJqOfpTtgTdWn1gXoNbxf/w==
X-WN-Post: microsoft.public.dotnet.framework.compactframework
From: "=?Utf-8?B?SmFzb2luIE0=?=" <
[email protected]>
References: <
[email protected]>
Subject: RE: Transferring a Dataset
Date: Thu, 15 Apr 2004 10:21:17 -0700
Lines: 28
Message-ID: <
[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.compactframework
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.compactframework:51047
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
Thank you for your help and quick responses.
I was going to use SQL Server CE because it was already on the device for
another project but I can see that it's not really required.
I'm running into problems trying to serialize my DataSet through a
NetworkStream. The source is a PC and the target is a PocketPC. I would
keep getting I XML exceptions on Line 1, Position 1 of "The data at the
root level is invalid.". I rewrote a portion of it to use a MemoryStream
and bypass all the socket stuff but I still get the same problem. I've
pasted the code below.
I can't understand what is going on. I've done searches for this problem
and only turned up one potential from a Google newsgroup: XmlTextReader
decoding issue. I've taken care of that, I believe, although it doesn't
seem to make much difference.
Any thoughts would be greatly appreciated.
DataSet ds = new DataSet();
ds.ReadXml( @"C:\library.xml" );
MemoryStream ms = new MemoryStream();
XmlTextWriter tempwriter = new XmlTextWriter( ms, Encoding.UTF8 );
ds.WriteXml( tempwriter, XmlWriteMode.WriteSchema );
ms.Seek( 0, SeekOrigin.Begin );
NameTable nt = new NameTable();
XmlNamespaceManager nsmanager = new XmlNamespaceManager(nt);
XmlParserContext context = new
XmlParserContext(nt,nsmanager,null,XmlSpace.None,System.Text.Encoding.UTF8);
XmlTextReader xmlreader = new XmlTextReader(
ms,XmlNodeType.Document,context);
DataSet dsIn = new DataSet();
dsIn.ReadXml( ms, XmlReadMode.ReadSchema);