CFLib.org – Common Function Library Project

FileReadCom(sPath)

Last updated October 10, 2002

author

Jeff Mathiot

Version: 1 | Requires: CF5 | Library: FileSysLib

Description:
Reads a text file, and returns content as a string. This UDF use VBScript File System Object (IIS Only).

Return Values:
Returns a string.

Example:

<!--- non live example --->
#ReadFileCom("c:\hello.htm")#

Parameters:

Name Description Required
sPath Path to file. Yes

Full UDF Source:

/**
 * Reads a text file, and returns content as a string.
 * 
 * @param sPath      Path to file. (Required)
 * @return Returns a string. 
 * @author Jeff Mathiot (brucewillisisnotdead@hotmail.com) 
 * @version 1, October 10, 2002 
 */
function ReadFileCom(sPath){
    var fileContent="";
    var oFSO=CreateObject("COM", "Scripting.FileSystemObject");
    var oFile=oFSO.OpenTextFile(sPath, 1, 0, 0);

    fileContent=oFile.ReadAll();
    oFile.Close();

    return fileContent;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson