Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

How Do I Transfer a Picture File through datasocket?


0 Kudos
Message 1 of 2
(3,027 Views)
Hello LMDS,
I would first recommend that you check our online resources at http://www.ni.com/datasocket. The FAQ section explains that DataSocket does not support reading and writing of binary files. However, you can circumvent this by loading the binary data into your program using native file IO routines, passing that binary data through DataSocket, and writing the data to a file, again using the native IO routines.
In Visual Basic, a graphics-file writer routine might look similar to:

Dim data() As Byte
Dim file As Integer
Dim length As Integer
file = FreeFile(0)
length = FileLen("c:\test.jpg")
ReDim data(length)
Open "c:\test.jpg" For Binary As file
Get file, , data
Close (file)
CWDataSocket1.data.Value = data ' store array in data object
CWDataSocket1.Upd
ate

You should probably pass the file length through DataSocket as well.

Jeremiah Cox
Applications Engineer
National Instruments
http://www.ni.com/ask
Message 2 of 2
(3,027 Views)