I am writing a C # class library to transfer large amounts of data through COM automation using IStream. It uses a call to CreateStreamOnHGlobal to create a stream, and methods in System.Runtime.InteropServices.COMTypes.IStream to work with it.
My question is, when transferring large amounts of data, the best way to maintain control over memory? Downloading 100MB + files to memory seems wasteful, and the client application will have to wait until this process is complete before downloading anything.
My plan was to create a stream with a sufficient size and write to it several times. Before writing the next piece of data, go back to the beginning and overwrite, starting from the beginning. I think about it correctly, and is there a better way to solve this problem?
c # stream interop com
polara
source share