?
Solved

encode file and send

Posted on 2006-06-10
2
Medium Priority
?
185 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

800 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