473,554 Members | 3,084 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("Emp loyees.xml",
FileMode.Open)
Dim objReader As New StreamReader(fs )
Dim responseString As String
responseString = objReader.ReadT oEnd
Dim sendBytes As [Byte]() =
Encoding.ASCII. GetBytes(respon seString)
networkStream.W rite(sendBytes, 0,
sendBytes.Lengt h)
objReader.Close ()
fs.Close()
Console.WriteLi ne("Message sent")
This is a part of my client code:

[code:1:4eac204a 01]
Try
Dim bytes(tcpClient .ReceiveBufferS ize) As Byte
networkStream.R ead(bytes, 0,
CInt(tcpClient. ReceiveBufferSi ze))
Dim returndata As String =
Encoding.ASCII. GetString(bytes )
Dim fs As FileStream
fs = New FileStream("Emp loyees.xml",
FileMode.Create )
Dim objWriter As New StreamWriter(fs )
objWriter.Write (returndata)
objWriter.Close ()
fs.Close()
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try
[/code:1:4eac204a 01]

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 2065
User FileStream.Read to get the byte array to send rather then converting
twice
"Henk" <kl*******@hotm ail-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("Emp loyees.xml",
FileMode.Open)
Dim objReader As New StreamReader(fs )
Dim responseString As String
responseString = objReader.ReadT oEnd
Dim sendBytes As [Byte]() =
Encoding.ASCII. GetBytes(respon seString)
networkStream.W rite(sendBytes, 0,
sendBytes.Lengt h)
objReader.Close ()
fs.Close()
Console.WriteLi ne("Message sent")
This is a part of my client code:

[code:1:4eac204a 01]
Try
Dim bytes(tcpClient .ReceiveBufferS ize) As Byte
networkStream.R ead(bytes, 0,
CInt(tcpClient. ReceiveBufferSi ze))
Dim returndata As String =
Encoding.ASCII. GetString(bytes )
Dim fs As FileStream
fs = New FileStream("Emp loyees.xml",
FileMode.Create )
Dim objWriter As New StreamWriter(fs )
objWriter.Write (returndata)
objWriter.Close ()
fs.Close()
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try
[/code:1:4eac204a 01]

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
20735
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 But the problem occures when i want to send a data with & sign (i.e: Firm=F&B). I try to solve this problem with using boundary, but i failed. Any...
0
913
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 has data send to server. 2. Client send the buffer block size. 3. Client send the actual buffer to the server. 4. Server send a flag 1 to client...
4
18536
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. send the zip file to WebService. 4. Unzip the zip file to XML. 5. Load XML file into DataSet. 6.Bulk copy the XML file to DataBase.
9
3129
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 other page, or is there something else like a stream which will be like a file. I am attempting to get a way from writing out a file and then...
1
1403
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 all works fine until the smtp server goes off line or something goes wrong. I'm then catching the 'Mail.Send' exception. Now there is the...
3
9734
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 and please help. Thanks in advance. Hugh
1
5984
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 to send. and i can't used printdialog, to select to which printer i need to send and number of pages and all. everything i need to hardcode. after...
4
10418
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, implementation must be open socket and send the buffer in chunks which is provided by the parameter.
2
1531
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. when I send GETARTICLES<EOF> it gets the articles from the DB and when I send something else it does that specific task. That all works fine. The...
1
3194
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 code for attachment, I am not able to send anything. I get blank email. Can you please help me on this? Here is the html form:
0
7570
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7493
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8008
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6113
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5411
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5133
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3537
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3525
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
808
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.