[Gambas-user] Read a binary file

Benoît Minisini gambas at ...1...
Sun Sep 18 14:47:40 CEST 2011


> Hi everyone
> 
> I'm doing a little webserver in Gambas. Everything is ok so far, but I'm
> having a hard time dealing with binary files (like images). Is there a
> way to read a file in a raw fashion?
> 
> I've tried to do an OPEN file FOR READ, and using a "byte" variable as
> buffer. But the bytes are read in this orden: 1, 0, 3, 2, 5, 4, 7, 6,
> etc... I think it's something about the endiannes.
> 
> Again, there is a way to read a file without any format constraints?
> Thank you!!!!

If you want to serve some image files, you don't have to read it byte by byte. 
You just have to open it and sent it where it is needed.

Print #DestinationFileOrSocket, File.Load(PathToBinaryFileOnTheServer);

Do not forget the ";", otherwise a newline will be added!

-- 
Benoît Minisini




More information about the User mailing list