- Option Explicit
-
- Private fsoFileSystem As New FileSystemObject
- Private fFile As File
- Private tsStream As TextStream
-
- Public Property Get FileName() As String
- FileName = fFile.Name
- End Property
-
- Public Property Let File(ByVal sFile As String)
- Set fFile = fsoFileSystem.GetFile(sFile)
- End Property
-
- Public Property Get Path() As String
- Path = fFile.Path
- End Property
-
- Public Property Get FileExtension() As String
- FileExtension = Right(fFile.Name, 3)
- End Property
-
- Public Function OpenFile()
- Set tsStream = fFile.OpenAsTextStream
- End Function
-
- Public Function CloseFile()
- tsStream.Close
- End Function
-
- Public Function ReadFile() As Variant
- If Not tsStream.AtEndOfStream Then
- ReadFile = tsStream.ReadLine
- Else
- ReadFile = "EOF"
- End If
- End Function
-
- Private Sub Class_Terminate()
- Set tsStream = Nothing
- Set fFile = Nothing
- Set fsoFileSystem = Nothing
- End Sub
-
Option Explicit
Private fsoFileSystem As New FileSystemObject
Private fFile As File
Private tsStream As TextStream
Public Property Get FileName() As String
FileName = fFile.Name
End Property
Public Property Let File(ByVal sFile As String)
Set fFile = fsoFileSystem.GetFile(sFile)
End Property
Public Property Get Path() As String
Path = fFile.Path
End Property
Public Property Get FileExtension() As String
FileExtension = Right(fFile.Name, 3)
End Property
Public Function OpenFile()
Set tsStream = fFile.OpenAsTextStream
End Function
Public Function CloseFile()
tsStream.Close
End Function
Public Function ReadFile() As Variant
If Not tsStream.AtEndOfStream Then
ReadFile = tsStream.ReadLine
Else
ReadFile = "EOF"
End If
End Function
Private Sub Class_Terminate()
Set tsStream = Nothing
Set fFile = Nothing
Set fsoFileSystem = Nothing
End Sub