Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Opening a file in binary mode
Message
De
05/09/2001 20:32:46
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
04/09/2001 12:34:31
Héctor Lizarraga
Gobierno Del Edo de Querétaro
Querétaro, Mexique
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00552106
Message ID:
00552924
Vues:
29
>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)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform