OVH Cloud OVH Cloud

Lecture d'une ligne dans un fichier texte

3 réponses
Avatar
Jean Saint Jalmes
Bonjour,

Existe t'il une API Windows ou une m=E9thode qui permet de=20
lire une ligne dans un fichier texte ouvert par l'API=20
CreateFileEx (=E0 l'image de la m=E9thode ReadLine d'un objet=20
TextStream) ?

Merci par avance.

Jean

3 réponses

Avatar
ng
Salut,

Essaye ceci :

Dim k As Integer, strBuff As String, tblLignes() As String
k = FreeFile
Open "c:1.txt" For Binary As #k
strBuff = String$(LOF(k), vbNulChar)
Get #k, , strBuff
Close #k
tblLignes = Split(strBuff, vbCrLf): strBuff = ""
For k = 0 To UBound(tblLignes)
MsgBox tblLignes(k)
Next


--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/



Jean Saint Jalmes a écrit :

Bonjour,

Existe t'il une API Windows ou une méthode qui permet de
lire une ligne dans un fichier texte ouvert par l'API
CreateFileEx (à l'image de la méthode ReadLine d'un objet
TextStream) ?

Merci par avance.

Jean


Avatar
J'utilise déjà cette méthode avec des petits fichiers mais
elle ne convient pas aux très gros fichiers (plusieurs
méga octets)

-----Message d'origine-----
Salut,

Essaye ceci :

Dim k As Integer, strBuff As String, tblLignes() As String
k = FreeFile
Open "c:1.txt" For Binary As #k
strBuff = String$(LOF(k), vbNulChar)
Get #k, , strBuff
Close #k
tblLignes = Split(strBuff, vbCrLf): strBuff = ""
For k = 0 To UBound(tblLignes)
MsgBox tblLignes(k)
Next


--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/



Jean Saint Jalmes a


écrit :

Bonjour,

Existe t'il une API Windows ou une méthode qui permet de
lire une ligne dans un fichier texte ouvert par l'API
CreateFileEx (à l'image de la méthode ReadLine d'un




objet
TextStream) ?

Merci par avance.

Jean




.



Avatar
ng
Bonjour,

Ah bon et pourquoi ?
Je l'utilise aussi pour des fichiers très important, c'est bcp plus rapide
que du Line Input...

Sinon regardez du coté du file mapping...

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/



a
écrit :

J'utilise déjà cette méthode avec des petits fichiers mais
elle ne convient pas aux très gros fichiers (plusieurs
méga octets)

-----Message d'origine-----
Salut,

Essaye ceci :

Dim k As Integer, strBuff As String, tblLignes() As String
k = FreeFile
Open "c:1.txt" For Binary As #k
strBuff = String$(LOF(k), vbNulChar)
Get #k, , strBuff
Close #k
tblLignes = Split(strBuff, vbCrLf): strBuff = ""
For k = 0 To UBound(tblLignes)
MsgBox tblLignes(k)
Next


--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/



Jean Saint Jalmes a écrit :

Bonjour,

Existe t'il une API Windows ou une méthode qui permet de
lire une ligne dans un fichier texte ouvert par l'API
CreateFileEx (à l'image de la méthode ReadLine d'un objet
TextStream) ?

Merci par avance.

Jean




.