Solved

encode file and send

Posted on 2006-06-10
2
184 Views
Last Modified: 2010-04-23
I have an app that is using sockets to dend data. Right now i can encode text from a textbox and send it to the server app where it is read, no problem.

What i need to do is grab a file that is already in binary form and send it to the server where i need to read it.
Can anyone give me pointers, i am lost in streamriters and advice from every corner of the web i can find. Seems simple but cant implement it

I tried this but all it sends is the file name (C:\blah\blah.dat etc) across to the server, not the file itself

Dim ofd As New OpenFileDialog
 ofd.ShowDialog(Me)
Dim Data() As Byte = System.Text.Encoding.UTF8.GetBytes(ofd.FileName)
openedSocket.Send(Data)


Thanks!!
0
Comment
Question by:Halon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 9

Accepted Solution

by:
jrscherer earned 500 total points
ID: 16879731
There are so many ways to open and read a file. It is confusing.

Here is a simple one, adapted to your problem:

        Dim ofd As New OpenFileDialog
        If ofd.ShowDialog(Me) <> Windows.Forms.DialogResult.OK Then Exit Sub
        Dim sr As New StreamReader(ofd.FileName)
        Dim Data() As Byte = System.Text.Encoding.UTF8.GetBytes(sr.ReadToEnd)
        sr.Close()
        sr.Dispose()

Jack.net
0
 
LVL 9

Expert Comment

by:jrscherer
ID: 16879737
Don't forget to import the namespace:  Imports System.IO  jack.net
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question