Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set myFSO = CreateObject("Scripting.Filesystemobject")
Set file1 = myFSO.CreateTextFile("C:\Testingbatch.txt",True)
file1.close()
Set file1= nothing
Set myFSO = nothing
If not myFSO.FileExists("C:\Testingbatch.txt") then
Set file2 = myFSO.OpenTextFile("C:\Testingbatch.txt",ForAppending,True)
end IF
file2.Write("Hi! we all cleared the test successfully")
file2.WriteBlankLines(3)
file2.Write("Max mark is 90 and every one got first class")
file2.Close()
set file2 = nothing
Set myFSO = nothing
Set file2 = myFSO.OpenTextFile("C:\Testingbatch.txt",ForReading)
'file should exists
'file should have data
'End of file
If myFSO.FileExists("C:\Testingbatch.txt") Then
While not (file2.AtEndOfStream)
msgbox file2.ReadLine()
Wend
Else
msgbox "File does not exists"
End If
file2.Close()
myFSO.MoveFile "C:\Testingbatch.txt","D:\Testingbatch.txt"
set file2 = nothing
Set myFSO = nothing