GetFileContentsThis is a featured page

Function GetFileContents(ByVal vsFilePath)
'Returns a string containing all the text in a file.
'The default folder depends on how the script is run.
'But it's usually the folder the script is in.
' Dim sContents
' sContents = GetFileContents("smr_mt571_extract.txt")
' MsgBox Len(sContents)
Dim oFso, oFile, oTs

Set oFso = CreateObject("Scripting.FileSystemObject")
Set oFile = oFso.GetFile(vsFilePath)
Set oTs = oFile.OpenAsTextStream(1) ' <-- 1 means ForReading
GetFileContents = oTs.Read(oFile.Size)
oTs.Close Set oTs = Nothing
Set oFile = Nothing
Set oFso = Nothing
End Function


No user avatar
2buck
Latest page update: made by 2buck , Dec 2 2006, 12:01 AM EST (about this update About This Update 2buck Edited by 2buck


view changes

- complete history)
Keyword tags: Vbscript (edit keyword tags)
More Info: links to this page

Anonymous  (Get credit for your thread)


There are no threads for this page.  Be the first to start a new thread.