|
ReadDataToString
string ReadDataToString(string
filename, int count)
Return
Value
Returns a string that represents the
content of the file. If the file does not exist or read operation
failed the result string is empty.
Parameters
filename
– the name of
the file.
count
- the maximum number of bytes to be read from the file or -1 to
read all bytes.
Remarks
Call this
function to read data from the file into a string.
Note that
calling this function repositions the read pointer in the file by
the number of bytes that have been read. In order to shift the read
pointer to the beginning of the file you need to close the file
first using CloseFile function.
Package
Plug in module:
nd_fileplg.npl
Example
The following
example demonstrates the use of ReadDataToString.
# Example for
ReadDataToString
string sFileName =
"c:\1.txt"
string sResult
if(IsFileExist(sFileName)
== FALSE)
Println("File ", sFileName,
" does not exist")
stop
endif
sResult = ReadDataToString(sFileName,
-1)
CloseFile(sFileName)
Println(sResult)
Output of the example
script:
Hello World!!!
My name is Bob.
|