FileSystemObject")
Set FileHandle = FileObject.OpenTextFile(Filename, ForReading)
Buffer=""
Do Until FileHandle.AtEndOfStream
Buffer = Buffer & FileHandle.ReadLine & vbCrLf
Loop
FileHandle.Close
ReadFromFile = Buffer
End Function
Sub WriteToFile(Filename, Text)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FileObject = CreateObject("Scripting.FileSystemObject")
If FileObject.FileExists(Filename) Then
Set FileHandle = FileObject.OpenTextFile(Filename, _
ForAppending)
FileHandle.Write vbCrLf
Else
Set FileHandle = FileObject.CreateTextFile(Filename)
End If
FileHandle.Write Text
FileHandle.Close
End Sub
The use of all of the ???file operations??? subroutines and functions listed in the
preceding section should be fairly self-explanatory, and they all work similarly.
For example, the FolderExists function and the FileExists function
are both nearly identical, except that FileExists checks for the existence of a
single file, while FolderExists checks for the existence of a folder (and can
be used to see whether a path refers to a folder or a file).
See the ???Rename Files with Search and Replace??? example
script, later in this chapter, for additional examples, as well
as a method for obtaining a list of all the files in a given
folder.
How to Create Windows Shortcuts and Internet Shortcuts
Include the following subroutine in your script to allow easy creation of
Internet Shortcuts (*.url ) and Windows Shortcuts (*.
Pages:
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738