Reads the data of a file from the current position to the end of the file.
Syntax: |
---|
DlxFile.ReadAll() |
Return Value
If the operation finishes successfully, it returns the text string, otherwise it returns an empty string.
Remarks
If the file is of binary type (opened with DlxApp.FILEOPEN_READBINARY) an empty string is returned.
Example
Copy code | |
---|---|
var filename = "demofile.txt";
// write file
var file = new DlxFile(filename, DlxApp.FILEOPEN_WRITETEXT);
if (file.IsValid())
{
for (var i = 0; i <= 90; i++)
file.Write(i.toString() + "° : " + Math.sin(i / 180 * Math.PI) + "\n");
file.Close();
}
// read file
file = new DlxFile(filename, DlxApp.FILEOPEN_READTEXT);
if (file.IsValid())
{
DlxApp.Printf("File size: %i characters", file.GetLength());
var txt = file.ReadAll();
file.Close();
DlxApp.Printf("File content: %s", txt);
}
else DlxApp.Printf("File not found.");
|