Ecrire dans un Byte Array
Bonjour,
J'ai un problème avec la manipulation des bytes, je récupère un message dans d'un tcpclient.getstream.read, voila ce que j'ai :
http://img16.imageshack.us/i/listview.png/
Voila ce avec quoi je récupère le message :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
Sub EcrireFlux(ByVal p_message As String)
Dim sendBytes As [Byte]() = Encoding.UTF8.GetBytes(p_message)
c_flux.Write(sendBytes, 0, sendBytes.Length)
End Sub
Function LireFlux(ByVal p_tcpclient As TcpClient, ByVal p_flux As NetworkStream) As String
Dim l_message As StringBuilder = New StringBuilder()
If p_flux.CanRead Then
If p_flux.DataAvailable Then
Dim bytes(p_tcpclient.ReceiveBufferSize) As Byte
p_flux.Read(bytes, 0, CInt(p_tcpclient.ReceiveBufferSize))
Dim returndata As String = Encoding.ASCII.GetString(bytes)
Return returndata
End If
Return "Données non disponible"
Else
Return "Flux non disponible"
End If
End Function |
Comment je peux régler ce problème afin d'avoir uniquement le mot souhaité et non les caractères qui suivent?
Merci :)