Closes the file associated with this object and makes the file unavailable for reading or writing.
Syntax: |
---|
DlxFile.Close() |
Return Value
If the file is closed correctly it returns true otherwise it returns false.
Remarks
If you haven't closed the file before destroying the object, the destructor closes it for you.
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())
{
while (!file.IsEOF())
DlxApp.Printf("%s", file.ReadLine());
file.Close();
}
else DlxApp.Printf("File not found.");
|