[vb.net] parcours dun fichier txt

mdaigre Messages postés 22 Date d'inscription jeudi 5 juin 2003 Statut Membre Dernière intervention 17 décembre 2003 - 2 déc. 2003 à 14:57
cs_labout Messages postés 1356 Date d'inscription samedi 8 décembre 2001 Statut Membre Dernière intervention 23 octobre 2006 - 2 déc. 2003 à 22:04
Salut
je cherche une façon de parcourir un fichier texte me permettant ensuite de trouver une chaine de caractere particuliere : comment faire ?!
merci d'avance

marlène

1 réponse

cs_labout Messages postés 1356 Date d'inscription samedi 8 décembre 2001 Statut Membre Dernière intervention 23 octobre 2006 8
2 déc. 2003 à 22:04
labout
Tout en haut avant le Public Class

Imports System.Timers

Dim myStreamReader As StreamReader

' Ensure that the creation of the new StreamReader is wrapped in a
' Try-Catch block, since an invalid filename could have been used.
Try
' Create a StreamReader using a Shared (static) File class.
myStreamReader = File.OpenText(txtFileName.Text)
' Read the entire file in one pass, and add the contents to
' txtFileText text box.
Me.txtFileText.Text = myStreamReader.ReadToEnd()
Catch exc As Exception
' Show the exception to the user.
MsgBox("File could not be opened or read." + vbCrLf + _
"Please verify that the filename is correct, " + _
"and that you have read permissions for the desired " + _
"directory." + vbCrLf + vbCrLf + "Exception: " + exc.Message)
Finally
' Close the object if it has been created.
If Not myStreamReader Is Nothing Then
myStreamReader.Close()
End If
End Try
End Sub

MystreamerFile contient le fichier
Pour les recherches, il faut utiliste
dim iPos as integer
ipos =instr(MyStreamerFile,"chaine Recherche")
Décvouper ensuite la chaine puis rechercher le suivant
0
Rejoignez-nous