Code:
Public Function ReadEOFData(ByRef FilePath As String) As String
On Error GoTo Err_Renamed
Dim sEOFBuf, sFileBuf, sChar As String
Dim lPos2, lFF, lPos, lCount As Integer
If Dir(FilePath) = "" Then GoTo Err_Renamed
lFF = FreeFile()
FileOpen(lFF, FilePath, OpenMode.Binary)
sFileBuf = Space(LOF(lFF))
FileGet(lFF, sFileBuf)
FileClose(lFF)
lPos = InStr(1, StrReverse(sFileBuf), GetNullBytes(30))
sEOFBuf = (Mid(StrReverse(sFileBuf), 1, lPos - 1))
ReadEOFData = StrReverse(sEOFBuf)
If ReadEOFData = "" Then
End If
Exit Function
Err_Renamed:
ReadEOFData = vbNullString
End Function
Public Function GetNullBytes(ByRef lNum As Object) As String
Dim Buf as String
Dim i As Short
For i = 1 To lNum
Buf = Buf & Chr(0)
Next
GetNullBytes = Buf
End Function
====================================
Exemple :
_ ofd1 : fichier initial
_ sfd1 : fichier final
_ eofpresent : boolean
Bouton de l'ouverture fichier initial :
If ReadEOFData(ofd1.Filename) = vbNullString Then
eofpresent = false
Else
eofpresent = true
End If
Enregistrement fichier final :
If eofpresent = true Then
ReadEOFData(sfd1.Filename)
Else
End If
J'aime:
RoRoH_AR
k-25 président :mouahaha: 