PC to PC file transfer

  • Thread starter Thread starter Hugh Janus
  • Start date Start date
H

Hugh Janus

Hi all,

I need to add to my app a computer to computer file transfer. I can't
use any components so I have to do this all from code. Basically, I
need to be able to input the recipients IP address and port (they run
the same app and press "listen" on a configured port to make their app
wait for a signal from the sender) and send any file. This needs to
work with binary files as well.

I know I need to use a FileStream but I have been banging my head
against a wall on just getting started. Does anyone have any
suggestions or have perhaps done this before and would like to share
some code?

I have been googling a while but none of the results I have come up
with have helped so I thought I'd ask fresh.

Please help!
TIA
 
hi, ive been working on this too, what youl want to look at is a Binary
Reader and a byte array. then use a network stream attached to your connected
socket to send the bytes to the other computer. then on the receiving
computer, use a binary writer to write the file using the received
information.
 
OK, this is a buffer issue it seems but I still cannot solve it.
Please help someone! I think it is a buffer issue because of the
following:


Dim numBytesRead As Integer
Dim BUFFER_SIZE As Integer = FTPClient.ReceiveBufferSize <--- this
value comes out at 8192

numBytesRead = NWstream.Read(bytesToRead, 0, BUFFER_SIZE)
FileSTR.Write(bytesToRead, 0, BUFFER_SIZE)


The file size is 211 bytes that I am testing with. So, the above code
writes out the 211 bytes and then files the file until it contains 8192
bytes. If I debug the code, after the 211 bytes have passed each
subsequent byte has a value of 0 (zero).

First of all, any ideas why it is doing this and not stopping when the
filestream has read it's 211 bytes like it is supposed to? And second,
any ideas on how to fix it? I tried setting the buffer size manually
to 211 bytes but then the file length is 8 bytes in size.

This is driving me crazy!

TIA
 
Back
Top