1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| ' Read a file into a string
Public Function IosFileReadStr(ByRef strPathName As String) As String
Dim hFile As Integer
Dim strData As String
On Error GoTo ErrHandler
' Get a free file handle
hFile = FreeFile
' Open file
Open strPathName For Binary Access Read As hFile
' Get file contents
strData = Space$(FileSystem.FileLen(strPathName))
Get #hFile, , strData
' Close file
Close hFile
IosFileReadStr = strData
Exit Function
ErrHandler:
IosFileReadStr = "Erreur dans la lecture du fichier"
End Function |