public bool SendToNavision([Out, MarshalAs(UnmanagedType.AsAny)] object COMStream, string fileName) { IStream COMStream1 = COMStream as IStream; this.rwBytes = Marshal.AllocHGlobal(4); int bytes = 0; byte[] buffer1 = new byte[0xafc8]; FileStream reader = new FileStream(fileName, FileMode.Open); //IStream COMStream = new IStream(); int _rwBytes = 0xafc8; bool result = true; int bytesRead = 0; do { bytesRead = reader.Read(buffer1, 0, _rwBytes); Marshal.WriteInt32(this.rwBytes, bytesRead); COMStream1.Write(buffer1, bytesRead, this.rwBytes); } while (bytesRead > 0); //COMStream1.Commit(0); reader.Close(); reader.Dispose(); Marshal.FreeHGlobal(this.rwBytes); return result; }
Rec.INIT; Rec.INSERT; Rec.BlobData.CREATEINSTREAM(InStr); CREATE(StreamTest); RetVal :=StreamTest.SendToNavision(InStr,'C:\toNAV.xml'); Rec.MODIFY; XMLPORT.IMPORT(80003, InStr); //The InStr is now empty!!!!!!!!!
Comments
In C#, you "just" need to implement the interface and call the underlaying .Net stream, which means really a wrapper call to all methods, which are usually one line of code each. As far as I remember, you just need to wrap the READ and WRITE and maybe make the wrapper object IDisposable.
I can try to look for the code if needed.
Regards,
“This posting is provided "AS IS" with no warranties, and confers no rights.”