Functions.FWrite Method (IntPtr, String, DWord)
FUNCTION FWrite( ptrHandle AS IntPtr, cBuffer AS STRING, nBytes AS DWORD ) AS DWORD
public static uint FWrite( IntPtr ptrHandle, string cBuffer, uint nBytes )
The low level File IO functions in the X# runtime are using .Net filestreams in the background. |
That means that the file handles returned by FOpen() and FCreate() are not 'normal' file handles, but unique identifiers that are used to find the underlying stream object in a collection of streams in the runtime.
That also means that you can't use file handles for functions such as FRead() and FWrite() that were not created in the X# runtime.
If you want to access the underlying FileStream, then you should call the function FGetStream(IntPtr)
1DEFINE F_BLOCK := 512 2... 3cBuffer := Space(F_BLOCK) 4nInfile := FOpen2("temp.txt", FO_READ) 5nOutfile := FCreate("newfile.txt", FC_NORMAL) 6lDone := FALSE 7DO WHILE !lDone 8 nBytesRead := FRead(nInfile, @cBuffer,; 9 F_BLOCK) 10 IF FWrite(nOutfile, cBuffer) < SLen(cBuffer) 11 ? DOSErrString(FError()) 12 lDone := TRUE 13 ELSE 14 lDone := (nBytesRead = 0) 15 ENDIF 16ENDDO 17FClose(nInfile) 18FClose(nOutfile)