TCPListener

G

Guest

hi, when u say "open the file" do u mean using the

System.IO.File.Open(filename)" method?

also how can i get the size of the file?

thanks
 
W

Wicksy

the System.IO.StreamReader object is pretty good, and has all the methods
you need:

Dim file1 As New StreamReader("D:\test.txt")
Dim filelen As Long = file1.BaseStream.Length
MsgBox(filelen) ' length of file

dim lineOfText as String

while file1.EndOfStream = False ' are we at the end of file yet?
lineOfText = file1.ReadLine() ' read line of file
end while

file1.close()


For sending chunks of data of a specific size (for network sending), use
ReadBlock() instead of ReadLine().
 
W

Wicksy

in exactly the same way as you did it for text.
The computer does not distinguish between "text" and "image". Its all just
1's and 0's to the machine.

The StreamReader can therefore read any data, and a TCP socket can send any
data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top