Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Opening a file in binary mode
Message
From
05/09/2001 20:32:46
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
04/09/2001 12:34:31
Héctor Lizarraga
Gobierno Del Edo de Querétaro
Querétaro, Mexico
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00552106
Message ID:
00552924
Views:
30
>Ok, but what happen when the file is very large? More than 1 MB

Héctor,

The following code is untested. It is supposed to read a 10-byte record at a time, starting at the beginning of the file.
lnFile = fopen("MyBinaryFile.bin")
if lnFile < 0
  MessageBox("Error opening file.")
else
  do while not feof(lnFile)
    lcBytes = fread(lnFile, 10)
    DoSomething(lcBytes)
  enddo
endif
fclose(lnFile)
HTH, Hilmar.

I used the low-level file functions a lot to get data from a legacy system. At that time, I hadn't learned yet to use FileToStr() and alines(). Would have worked, since the files were not extraordinarily large!

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform