[Progress Communities] [Progress OpenEdge ABL] Forum Post: RE: Using NameValueCollection and webClient

Status
Not open for further replies.
T

tbergman

Guest
The UploadValues method of the web client returns a Byte array. def var foo as "System.Byte[]". foo = . Now you need to do something with the byte array. You could either pass it to another .net method if appropriate or convert it to something usable in the Progress world. The method below will convert a byte array to a memptr. From there you can do what's needed. METHOD PUBLIC STATIC MEMPTR ByteArrayToMemptr( nBytes AS "System.Byte[]" ): DEFINE VARIABLE nPtr AS System.IntPtr NO-UNDO. DEFINE VARIABLE mPtr AS MEMPTR NO-UNDO. DEFINE VARIABLE PointerLoc AS INT64 NO-UNDO. set-size(mPtr) = nBytes:LENGTH. /* In 11.7, due to the new compile used, Progress is much more likely to choose a memory pointer that exceeds the 32 bit limit of an integer. Using this intermediate INT64 solves the problem */ PointerLoc = GET-POINTER-VALUE(mPtr). nPtr = NEW System.IntPtr(PointerLoc). System.Runtime.InteropServices.Marshal:Copy(nBytes, 0, nPtr, nBytes:LENGTH). RETURN mPtr. FINALLY: nPtr = ?. nBytes = ?. set-size(mPtr) = 0. END. END METHOD.

Continue reading...
 
Status
Not open for further replies.
Top