Public Function GetFilePart(ByVal sPath As String, ByVal lLineStart As Long, ByVal lLineStop As Long) As String
Dim FReader As StreamReader
Dim Res As String = String.Empty
Dim Ret As String = String.Empty
Dim Count As Integer = 0
'La encore comme dans le snippet de PCPT,
'lLineStart et lLineStop doivent être logiques, pas de la ligne 8 à 5 par exemple
'On vérifie l'existence du fichier
If File.Exists(sPath) Then
'ouverture du fichier
FReader = New StreamReader(sPath, System.Text.Encoding.GetEncoding("iso-8859-1"))
'tant que nous ne somme pas à la ligne
'souhaitée
While Count < (lLineStart - 1)
Call FReader.ReadLine
Count += 1
End While
While Count < lLineStop
'on vérifie de ne pas être arrivé à la fin
'du flux
If Not FReader.EndOfStream Then
'on lit la ligne
Ret = FReader.ReadLine
'on concatène avec le résultat
Res = String.Concat(Res, Ret, Environment.NewLine)
Count += 1
Else
Exit While
End If
End While
End If
Return Res
End Function
|
| By Renfield |