473,246 Members | 1,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

byte Array To File Stream

Hello,

I have a byte array and i must send(to blocks) to remote class
In the remote class i write a file stream......

How?
In my sample i send stream...

Code CLIENT:

FSource = New FileStream("c:\test.tif", FileMode.Open)
While FSource.Position < FSource.Length - 1
Call RemoteObject.WriteStream(FSource)
End While

Code SERVER:

Public Sub WriteStream(ByVal SourceStream As Stream)
Dim FOutput As FileStream

If Not File.Exists("c:\testremote.tif") Then
FOutput = New FileStream("c:\testremote.tif", FileMode.CreateNew,
FileAccess.ReadWrite)
Else
FOutput = New FileStream("c:\testremote.tif", FileMode.Append,
FileAccess.Write)
End If

Dim BWriter As BinaryWriter = New BinaryWriter(FOutput)
Dim i As Integer
Dim intBytesRead As Integer
Const intSize As Integer = 4096
Dim bytes(intSize) As Byte
intBytesRead = SourceStream.Read(bytes, 0, intSize)
BWriter.Write(bytes, 0, intBytesRead)
BWriter.Close()
FOutput.Close()
End Sub
Jul 22 '05 #1
1 9530


Gigi wrote:
Hello,

I have a byte array and i must send(to blocks) to remote class
In the remote class i write a file stream......

How?


Are you just trying to write to a remote strem? Why dont you simply use
the "Read" and "Write" methods on the Stream with the data you wish to
write. whether it is remote or not should not matter.

remote.Write(bytes, 0, bytes.Length);

If you are trying to pass a stream to a remote class, you can "just do it":

public class RemoteThingy {
void f(Stream s) {
using ( TextWriter w = new StreamWriter(s) )
w.WriteLine("Hello Remote!");
s.Flush();
}
}

public class Client {
RemoteThingy remote = ...; // obtain remote instance
using ( Stream s = new FileStream("mytest.txt")
remote.f(s);
}

--
Helge Jensen
mailto:he**********@slog.dk
sip:he**********@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Srilatha | last post by:
Hi, I want to read a file as a Byte Array Input Stream in VB.Net. How can I declare a Byte Array Input Stream?
2
by: Sathyaish | last post by:
I am using MCI (winmm.dll) to read, record and playback sound. For now, I am doing this with disk files instead of realtime doing it straight from the memory. If I want to stream/relay/transmit...
3
by: Nick | last post by:
I have found a class that compresses and uncompresses data but need some help with how to use part of it below is the deflate method which compresses the string that I pass in, this works OK. At...
1
by: steve | last post by:
I need to get byte values from an object into a byte in order to write the bytes to file. An object (vSound) is passed to a function. From the Autos window I can see that the Value of vSound is...
0
by: CroDude | last post by:
Hi all! I have problems when writting bitmap to a byte array and after reading it back form byte to Bitmap object. What I do is this: First I throw Bitmap to a memory-stream and then I write it...
1
by: Angel Filev | last post by:
Hi everyone, I am trying to store a file as a binary array in an "image" field in SQL Server 2000 database. It works OK except for the ".PDF" files, which I believe get corrupted in the process...
8
by: frekster | last post by:
Hi. I used to be able to do this easily in vb 6 via looping and preserving the source array data/size etc. How can I do this in vb.net? I've been trying for a while now and this should be...
3
by: Terry | last post by:
In the code below, I open a file using filestream, copy it to a byte array, and the write that array out to a new file. But when I check the size of the original file and the new file, the new...
0
by: jcvoon | last post by:
Hi: I use the following code to copy the contents of the XMLDocument to byte array Dim xmlDoc as New XMLDocument Dim stream As New MemoryStream Dim buffers() As Byte ...
1
by: RGarg06 | last post by:
Hi, I am trying to read a buffer from a file and then pass that buffer to a C++ dll as follows. While debugging it tells me that byte array received is a Bad Ptr. Any help will be appreciated. ...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.