StreamWriter doesn't accept a xml data string in it's constructor, it's a
path to the file. Instead, you could use the MemoryStream:
Dim ms As MemoryStream = NewMemoryStream(myBytes)
writer = New XmlTextWriter(ms)
HTH... Alex
--
Alex Yakhnin, .NET CF MVP
www.intelliprog.com
www.opennetcf.org
"salim" wrote:
> Hi guys,
>
> whats wrong with below code!!!!!! it just doesn't work
>
> All i want to do is Return my typed dataset as diffgram in bytes and receive
> it in my PPC application and convert it back to dataset
>
> WebService code Snippet:
>
> myDsHandIT2.WriteXml(stream, XmlWriteMode.DiffGram)
> myBytes = stream.ToArray()
> return myBytes
>
> PPC Code Snippet :
>
>
> Dim myBytes() As Byte
> Try
> myBytes = objHandIT2.TestLoadData(Me.mUsername, Me.mPassword,
>
> Me.mWebServiceUrl, Me.IPAddress)
> strresult = utf.GetString(myBytes, 0, myBytes.Length)
> Me.writeXML(strresult, "\Program Files\Data\test.xml", "\Program
> Files\Data\test.xsd")
> Catch ex As Exception
> MessageBox.Show(ex.ToString)
> End Try
>
>
> Public Function writeXML(ByVal myStream As String, ByVal FileName As
> String, ByVal SchemaName As String) As Boolean
>
> Dim stream As StreamWriter = Nothing
> Dim writer As XmlTextWriter = Nothing
> Dim isOk As Boolean
> Dim ds As New DataSet
>
> Try
> stream = New StreamWriter(myStream) <---------- Goes bang over
> here
> writer = New XmlTextWriter(stream)
>
> If (Not (ds.Tables.Count = 0)) Then
> ' Save out to file
> ds.WriteXml(writer, XmlWriteMode.DiffGram)
> 'write schema also
> ds.WriteXmlSchema(SchemaName)
> End If
>
> isOk = True
> Catch ex As Exception
> isOk = False
> MessageBox.Show(ex.ToString)
> Finally
> If Not (stream Is Nothing) Then
> stream.Close()
> End If
> End Try
> Return isOk
> End Function
>
> Regards
>
> Salim