Get Contents of a File

Search

 by Remas Wojciechowski

This function returns a string representing the contents of a file. The only attribute is the full physical path to the file to be read.

' ### Returns the contents of a file as a string
Function File_ContentsToString(ByVal strFilePath)
   Dim strTemp
   Dim objFSO
   Dim objF
   Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
   Set objF = objFSO.OpenTextFile(strFilePath)
   Set objFSO = Nothing
   strTemp = objF.ReadAll
   objF.Close
   Set objF = Nothing
   File_ContentsToString = strTemp
End Function