Bonjour tout le monde,
j'ai écris un script permettant de lire le contenu d'un fichier texte puis le formater et l'afficher à l'écran. chaque ligne lue est traitée puis ajoutée dans une chaine de type string. la chaine construite est affichée à l'écran dans un textbox multiligne. voici une partie du code :
1 2 3 4
|
'LECTURE FICHIER
fs = New FileStream(filename, FileMode.Open, FileAccess.Read)
sr = New StreamReader(fs) |
Lecture des lignes du fichier
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
content = sr.ReadLine.Trim
While Not content Is Nothing
If content.StartsWith("Solde_PME") Then
chaine = content.Replace("Solde_PME>LON/6=", "Solde PME " + s.PadLeft(14)).Trim + ControlChars.CrLf
End If
.
.
.
.
If content.StartsWith("Code_Etape") Then
If content.StartsWith("Code_Etape_ET1") Then
chaine += content.Replace("Code_Etape_ET1>ASC/30=", "Code Etape Et.1 " + s.PadLeft(8)).Trim + ControlChars.CrLf
End If
If content.StartsWith("Code_Etape_ET2") Then
chaine += content.Replace("Code_Etape_ET2>ASC/30=", "Code Etape Et.2 " + s.PadLeft(8)).Trim + ControlChars.CrLf
End If
If content.StartsWith("Code_Etape_ET3") Then
chaine += content.Replace("Code_Etape_ET3>ASC/30=", "Code Etape Et.3 " + s.PadLeft(8)).Trim + ControlChars.CrLf
chaine += "------------------------------------------------------" + ControlChars.CrLf
End If
If content.StartsWith("Code_Etape1") Then
chaine += content.Replace("Code_Etape1>ASC/6=", "Code étape 1 " + s.PadLeft(11)).Trim + ControlChars.CrLf
End If
If content.StartsWith("Code_Etape2") Then
chaine += content.Replace("Code_Etape2>ASC/6=", "Code étape 2 " + s.PadLeft(11)).Trim + ControlChars.CrLf
End If
If content.StartsWith("Code_Etape3") Then
chaine += content.Replace("Code_Etape3>ASC/6=", "Code étape 3 " + s.PadLeft(11)).Trim + ControlChars.CrLf
End If
If content.StartsWith("Code_Etape4") Then
MsgBox("je suis en étape 4")
chaine += content.Replace("Code_Etape4>ASC/6=", "Code étape 4 " + s.PadLeft(11)).Trim + ControlChars.CrLf
MsgBox(chaine)
End If
End If
content = sr.ReadLine()
End While |
Le problème est que l'étape 4 ne s'affiche pas même s'il existe bien dans le fichier. j'ai rajouté un msgbox :
MsgBox("je suis en étape 4")
J'ai bien le message qui s'affiche. j'ai rajouté mais la chaine ne contient pas la ligne de l'étape 4.
Avez-vous une idée du problème ?
Si vous avez des question , n'hésitez pas. Merci
Partager