I just can't figure out why this isn't working. The file which should be read is present, not open in another program or running, but the RawRead fails:
MsgBox II shows the correct length. In the case of an exe (Lux.exe) MsgBox III shows 0; in the case of a txt (Text.txt) MsgBox III is not shown at all.
Code: Select all
FileP := A_ScriptDir . "\Lux.exe" ; FileP := A_ScriptDir . "\Text.txt" FileGetSize, FileS, %FileP% MsgBox (I) FileS: %FileS% VarSetCapacity(Data, Size) Offset := 0 , oF := "" , oF.Length := 0 If !oF := FileOpen(FileP, "r") Return oF.Pos := 0 Len := oF.Length MsgBox (II) Len: %Len% Bytes := oF.RawRead(&Data+Offset, Len) MsgBox (III) Bytes: %Bytes% Offset += Len oF.Close()