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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
| Function ReadAllFile() As String
Dim fs As FileStream
Dim sr As StreamReader
Dim dir As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\idBadge"
Dim ret As String = ""
Dim content As String
Dim chaine As String
Dim filename As String = System.IO.Path.Combine(dir, "OUT" + UserConnecte + "1.txt")
Try
'LECTURE FICHIER
fs = New FileStream(filename, FileMode.Open, FileAccess.Read)
sr = New StreamReader(fs)
Dim lieu_nais, date_nais, prenom, boursier, lecteur, Ine As String
'Return chaine
'LECTURE FICHIER EN ENTIER
content = sr.ReadLine.Trim 'lire le Num Crypté sur la 1ère ligne
Dim s As String = ": "
Dim pme As String = ""
Dim soldepme As String
Dim datepme As String = ""
chaine += "N° CSN " + s.PadLeft(17) + content + vbCrLf
content = sr.ReadLine.Trim
'_CSNCrypte = sr.ReadLine.Trim 'lire le Num Crypté sur la 1ère ligne
'content = sr.ReadLine.Trim
If content = "0" Then 'Lire résultat sur la 2ème ligne: 0 -> Succès
content = sr.ReadLine.Trim
While Not content Is Nothing
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 + vbCrLf
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 + vbCrLf
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 + vbCrLf
chaine += "------------------------------------------------------" + vbCrLf
End If
If content.StartsWith("Code_Etape1") Then
chaine += content.Replace("Code_Etape1>ASC/6=", "Code étape 1 " + s.PadLeft(11)).Trim + vbCrLf
End If
If content.StartsWith("Code_Etape2") Then
chaine += content.Replace("Code_Etape2>ASC/6=", "Code étape 2 " + s.PadLeft(11)).Trim + vbCrLf
End If
If content.StartsWith("Code_Etape3") Then
chaine += content.Replace("Code_Etape3>ASC/6=", "Code étape 3 " + s.PadLeft(11)).Trim + vbCrLf
End If
If content.StartsWith("Code_Etape4") Then
chaine += content.Replace("Code_Etape4>ASC/6=", "Code étape 4 " + s.PadLeft(11)).Trim + vbCrLf
End If
End If
If content.StartsWith("Version_Etape") Then
If content.StartsWith("Version_Etape1") Then
chaine += content.Replace("Version_Etape1>ASC/3=", "Version étape 1 " + s.PadLeft(8)).Trim + vbCrLf
End If
If content.StartsWith("Version_Etape2") Then
chaine += content.Replace("Version_Etape2>ASC/3=", "Version étape 2 " + s.PadLeft(8)).Trim + vbCrLf
End If
If content.StartsWith("Version_Etape3") Then
chaine += content.Replace("Version_Etape3>ASC/3=", "Version étape 3 " + s.PadLeft(8)).Trim + vbCrLf
End If
If content.StartsWith("Version_Etape4") Then
chaine += content.Replace("Version_Etape4>ASC/3=", "Version étape 4 " + s.PadLeft(8)).Trim + vbCrLf
End If
End If
If content.Trim.StartsWith("Finalite_Etape") Then
If content.StartsWith("Finalite_Etape1") Then
chaine += content.Trim.Replace("Finalite_Etape1>ASC/1=", "Finalité étape 1 " + s.PadLeft(7)).Trim + vbCrLf
End If
If content.Trim.StartsWith("Finalite_Etape2") Then
chaine += content.Trim.Replace("Finalite_Etape2>ASC/1=", "Finalité étape 2 " + s.PadLeft(7)).Trim + vbCrLf
End If
If content.StartsWith("Finalite_Etape3") Then
chaine += content.TrimEnd.Replace("Finalite_Etape3>ASC/1=", "Finalité étape 3 " + s.PadLeft(7)).Trim + vbCrLf
End If
If content.Trim.StartsWith("Finalite_Etape4") Then
chaine += content.TrimEnd.Replace("Finalite_Etape4>ASC/1=", "Finalité étape 4 " + s.PadLeft(7)).Trim + vbCrLf
End If
End If
If content.StartsWith("Niveau_Etape") Then
If content.StartsWith("Niveau_Etape1") Then
chaine += content.Replace("Niveau_Etape1>ASC/2=", "Niveau étape 1 " + s.PadLeft(9)).Trim + vbCrLf
chaine += "------------------------------------------------------" + vbCrLf
End If
If content.StartsWith("Niveau_Etape2") Then
chaine += content.Replace("Niveau_Etape2>ASC/2=", "Niveau étape 2 " + s.PadLeft(9)).Trim + vbCrLf
chaine += "------------------------------------------------------" + vbCrLf
End If
If content.StartsWith("Niveau_Etape3") Then
chaine += content.Replace("Niveau_Etape3>ASC/2=", "Niveau étape 3 " + s.PadLeft(9)).Trim + vbCrLf
chaine += "------------------------------------------------------" + vbCrLf
End If
If content.StartsWith("Niveau_Etape4") Then
chaine += content.Replace("Niveau_Etape4>ASC/2=", "Niveau étape 4 " + s.PadLeft(9)).Trim + vbCrLf
End If
End If
content = sr.ReadLine()
End While
End If
fs.Close()
Return chaine
Catch ex As Exception
Return ex.Message
Finally
If Not fs Is Nothing Then fs.Close()
If Not sr Is Nothing Then sr.Close()
End Try
End Function |