string = FileRead(pathname)
Example Usage:
Writes the contents of File.txt in folder New Folder to the browser.ASP Source Code:
<% = FileRead( server.mappath("/New Folder/File.txt") ) %> Writes the contents of File.txt in folder New Folder to a variable named a. <% dim a a = FileRead( server.mappath("/New Folder/File.txt") ) %>
<% Private Function FileRead(byVal pathname) dim objFSO, objFile, tmp On Error Resume Next Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(pathname, 1, False) tmp = objFile.ReadAll If Err Then FileRead = Null Else FileRead = tmp End If objFile.Close Set objFile = Nothing Set objFSO = Nothing On Error GoTo 0 End Function %>