Hello
I wrote a code to d.l message from newgroups and display it in text box, the
code work fine but when the message is large it only display 27k from the
message. any idea how to fix it?
Code:
Imports System.Xml
Imports System.Net.Sockets
Imports System.Text
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim _username As String = "********"
Dim _password As String = "********"
Dim tcpClient As New TcpClient
Dim sendBytes As [Byte]()
Dim _buffer As String
tcpClient.Connect("news.giganews.com", 119)
Dim networkStream As NetworkStream = tcpClient.GetStream()
'Read the Welcome message into a byte buffer.
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
'send username to the server
sendBytes = Encoding.ASCII.GetBytes("AUTHINFO USER " & _username & vbCrLf)
networkStream.Write(sendBytes, 0, sendBytes.Length)
ReDim bytes(tcpClient.ReceiveBufferSize)
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Send Passwrod to the server
sendBytes = Encoding.ASCII.GetBytes("AUTHINFO PASS " & _password & vbCrLf)
networkStream.Write(sendBytes, 0, sendBytes.Length)
ReDim bytes(tcpClient.ReceiveBufferSize)
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
'reset the buffer
_buffer = ""
'send command to get the message body
sendBytes = Encoding.ASCII.GetBytes("BODY
<46***********************@tele2news.tweaknews.nl> " & vbCrLf)
networkStream.Write(sendBytes, 0, sendBytes.Length)
' Read the NetworkStream into a byte buffer.
ReDim bytes(tcpClient.ReceiveBufferSize)
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
_buffer = _buffer & Encoding.GetEncoding("windows-1255").GetString(bytes)
While networkStream.DataAvailable = True
ReDim bytes(tcpClient.ReceiveBufferSize)
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
_buffer = _buffer & Encoding.GetEncoding("windows-1255").GetString(bytes)
End While
TextBox1.Text = _buffer
End Sub
End Class