|
Text Files |
Top Previous Next |
|
What is translated > File Input and Output > Text Files A Delphi TextFile variable is translated to the C# class TextFile.
TextFile is derived from TTextRec. TTextRec contains the shared implementation for text input and output.
A text file variable is normally initialized as follows:
TextFile myFile = TextFile.CreateRecord();
AssignFile associates the variable with a file name:
AssignFile(myFile, "Test.txt");
Rewrite creates or replaces the file and opens it for writing:
Rewrite(myFile);
Write and WriteLn write values to the file:
WriteLn(myFile, "Hello"); WriteLn(myFile, "World");
Append reopens an existing text file and writes new data at the end:
CloseFile(myFile); Append(myFile); WriteLn(myFile, "Final line");
Reset opens the file for reading:
CloseFile(myFile); Reset(myFile);
CloseFile closes the current reader or writer. It does not remove the file name assigned by AssignFile. The same TextFile variable can therefore be reopened. |
|
This page belongs to the Delphi2C# Documentation |
Delphi2C# home Content |