ReadTextFile

The following example demonstrates how to create a text file using the scripting FileSystemObject.

Example

Option Explicit

'------------------------------------------------------------------------------

' Subroutine: ReadTextFile

' Purpose:    Reads a text file and dumps it to the command line.

'------------------------------------------------------------------------------

Sub ReadTextFile

Dim objFSO, objFile, strFileName, strLine

Const ForReading = 1

strFileName = Rhino.OpenFileName("Open", "Text Files (*.txt)|*.txt||")

If IsNull(strFileName) Then Exit Sub

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile(strFileName, ForReading)

While Not objFile.AtEndOfStream

strLine = objFile.ReadLine

Rhino.Print strLine

Wend

objFile.Close

Set objFSO = Nothing

End Sub