Hi, I made a client and server application. I'm trying to send an xml
file from the server to the client. It works, but there are some
problems: the file the client receives is the same as the file the
server sends but there are some spaces added at the end, and this
causes that I can't open the file correctly.
This is part of my server code:
Dim fs As FileStream
fs = New FileStream("Employees.xml",
FileMode.Open)
Dim objReader As New StreamReader(fs)
Dim responseString As String
responseString = objReader.ReadToEnd
Dim sendBytes As [Byte]() =
Encoding.ASCII.GetBytes(responseString)
networkStream.Write(sendBytes, 0,
sendBytes.Length)
objReader.Close()
fs.Close()
Console.WriteLine("Message sent")
This is a part of my client code:
[code:1:4eac204a01]
Try
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0,
CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String =
Encoding.ASCII.GetString(bytes)
Dim fs As FileStream
fs = New FileStream("Employees.xml",
FileMode.Create)
Dim objWriter As New StreamWriter(fs)
objWriter.Write(returndata)
objWriter.Close()
fs.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
[/code:1:4eac204a01]
Can somebody tell me what I am doing wrong or give me another way to
send the file?
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com 1 2055
User FileStream.Read to get the byte array to send rather then converting
twice
"Henk" <kl*******@hotmail-dot-com.no-spam.invalid> wrote in message
news:40**********@Usenet.com... Hi, I made a client and server application. I'm trying to send an xml file from the server to the client. It works, but there are some problems: the file the client receives is the same as the file the server sends but there are some spaces added at the end, and this causes that I can't open the file correctly.
This is part of my server code:
Dim fs As FileStream fs = New FileStream("Employees.xml", FileMode.Open) Dim objReader As New StreamReader(fs) Dim responseString As String responseString = objReader.ReadToEnd Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString) networkStream.Write(sendBytes, 0, sendBytes.Length) objReader.Close() fs.Close() Console.WriteLine("Message sent")
This is a part of my client code:
[code:1:4eac204a01] Try Dim bytes(tcpClient.ReceiveBufferSize) As Byte networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize)) Dim returndata As String = Encoding.ASCII.GetString(bytes) Dim fs As FileStream fs = New FileStream("Employees.xml", FileMode.Create) Dim objWriter As New StreamWriter(fs) objWriter.Write(returndata) objWriter.Close() fs.Close() Catch ex As Exception MsgBox(ex.ToString) End Try [/code:1:4eac204a01]
Can somebody tell me what I am doing wrong or give me another way to send the file?
Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Fatih BOY |
last post by:
Hi,
I want to send a report from a windows application to a web page like
'report.asp'
Currently i can send it via post method with a context like
local=En&Username=fatih&UserId=45&Firm=none...
|
by: zhimin |
last post by:
Hi,
I'm writing a program to send large file(100m) through dotnet using
TCPListener & TCPClient, I'm sending the file with a ask and response loop:
1. Client send a flag 1 to server indicate it...
|
by: ad |
last post by:
I want to send a DataSet to WebService, but the DataSet if too huge(there
about 50000 records, and 50 fields every record).
My solution is
1.save the DataSet as XML file,
2.zip the XML file.
3....
|
by: eswanson |
last post by:
I have a web page I need to post a file plus some other fields to it. How
can I do this from a asp.net page. I know I can send individual fields to the
other page, but how do I send a file to the...
|
by: Kees |
last post by:
Hi there,
Im having a bit of trouble with a logfile I use to put logevents in with a
streamwriter, after I have written in this file I want to send the file as a
mailattachment with smtp.
This...
|
by: =?Utf-8?B?SHVnaA==?= |
last post by:
Hi There,
I use follow code to send email inside VB.NET 2005. It does not work well.
Error message of "Failure sending email" would occue. However, email was
sent out sometimes. I am confused...
|
by: remya1000 |
last post by:
how to send a .txt file to a printer.
after creating a .txt file i need to send that .txt file to a printer.using vb.net
and while sending that file to printer i need to tell, which printer i need...
|
by: gvijayaratnam |
last post by:
Hi All,
I have a fn prototype as follows
void print ( char *Buffer, usigned long bufferSize, int chunkSize );
This fn will accept binary file buffer and the buffer size and the chunk
size,...
|
by: SvenV |
last post by:
I based my program on the asynchronous client/server example on msdn. There weren't too many modifications to the original code. I just created some extra code to response to different messages. F.e....
|
by: deepaks85 |
last post by:
Dear All,
I want to send some data through a form with Multiple attachment in an HTML Format. I have tried it but it is not working for me. I am able to send data without attachment but with the...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |