472,337 Members | 1,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,337 software developers and data experts.

send file

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
Nov 20 '05 #1
1 2013
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

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
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...
0
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:...
4
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...
9
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...
1
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...
3
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. ...
1
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...
4
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...
2
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...
1
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...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.