Discussion:
File transfer
(too old to reply)
Rami
2008-05-27 12:55:12 UTC
Permalink
A beginner question-
Is remoting appropriate for file transfer of 2 mb files?
Regards

rami
Tommaso Caldarola
2008-05-27 12:32:16 UTC
Permalink
Post by Rami
A beginner question-
Is remoting appropriate for file transfer of 2 mb files?
Regards
I'm using Remoting to transfer of 500K chunk of bytes.

tomb
Kevin J. Stricklin
2008-05-27 19:43:02 UTC
Permalink
When transferring large quantities of data, consider using a Stream object.
The use of a Stream object will automatically break the data into smaller
chucks.

As an example, here's a simple Remoting object:

public class RemotingObject : MarshalByRefObject
{
public Stream GetLargeAmountsOfData()
{
return new FileStream("c:\\Temp\\data.dat", FileMode.Open);
}
}

Here's how a client might call and use this object to retrieve data in chunks.


public class Client
{
public void GetRemotingData()
{
RemotingObject ro = Activator.GetObject(typeof(RemotingObject),
"tcp://localhost:1234/RO.rem");
Stream s = ro.GetLargeAmountsOfData();

byte[] data = new byte[1024 * 64];
int bytesToRead = s.Length();
while (bytesToRead > 0)
{
bytesToRead -= s.Read(data, 0, data.Length);
//do something with the data
}
}
}

Loading...