Option Explicit
Const ForReading = 1 ' Opens the file for reading
Const ForWriting = 2 ' Opens the file for writing
Const ForAppending = 8 ' Opens the file for appending
Const TristateUseDefault = -2 ' Opens the file using the system default
Const TristateTrue = -1 ' Opens the file as Unicode
Const TristateFalse = 0 ' Opens the file As ASCII
Sub Main
WriteFile
ReadFile
End Sub
Sub WriteFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.CreateTextFile("testfile.txt", true, true)
a.WriteLine("This is a test.")
'a.WriteLine("The quick brown fox jumped over the lazy dog.")
a.Close
End Sub
Sub ReadFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.OpenTextFile("testfile.txt", ForReading, false, TristateTrue)
Do While Not a.AtEndOfStream
a.Read(1)
Loop
a.Close
End Sub
This post has been edited by SixOfEleven: 27 June 2012 - 06:46 AM

New Topic/Question
Reply




MultiQuote



|