473,508 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9554


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
14054
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
4314
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
9496
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
25631
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
3565
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
5707
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
4569
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
7293
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
2344
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
4360
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
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7328
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7049
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
422
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.