ldam
ldam

Reputation: 4595

Is there a way to perform zero-copying in .NET?

In Java I'd use the java.nio library and use FileChannel.transferTo() and FileChannel.transferFrom(). Is there something similar in (specifically) C# or am I going to have to load some unamanaged .dll from somewhere? Google has not been useful in this case.

Edit: I should note that I'm targeting .NET 3.5.

Upvotes: 9

Views: 2979

Answers (1)

Sepster
Sepster

Reputation: 4848

I think the best performing equivalent might be UnmanagedMemoryStream.

This class supports access to unmanaged memory using the existing stream-based model and does not require that the contents in the unmanaged memory be copied to the heap.

Although I've never had cause to do this, so can't vouch for appropriateness of this class (or of using unmanaged code/memory in your scenario).

Upvotes: 2

Related Questions