delphi 用流来读取txt文件(Delphi reads the txt file with the stream)
delphi 用流来读取txt文件(Delphi reads the txt file with the stream)
Delphi stream to read the TXT file.Txt if the ten million, I would like to buy 30 sets of houses to rent to others, every day receives a rent. Wow Kaka ~ ~ full horse is not necessarily the prince, may be Tang Seng; with wings are not angels, sometimes is a bird. Delphi used to read the TXT file stream
Author: anonymous sources: the finishing time of release: 2008-11-6 15:39:32TXT is a text file to ACSII data file storage. Can only store character data in the TXT file, so the file's portability and versatility is very strong, has high usability, and is widely used for this type of file, so Delphi provides better support. At present the most popular on the Internet XML file is a text file. TXT text file operation is very simple, the specific operation process is as follows:
1. first to file a statement of the type TextFile pointer. Such as: VAR MyFile:TEXTFile.
2. and then use the AssignFile method to associate the file pointer declared with external TXT files. AssignFile (FileName); FileName can be the full path name, can only be a file name. For the latter system will be in the current directory search.
3. initializes the read and write in three ways: Reset to open the file and read the file pointer to the file; Rewrite is written to create a new file; Append to write open existing file and the file pointer to the location at the end of the file.
4. read or write text. Readln can read a line of text, writeln can write a line of text to a file.
5. finally used Closefile method to close the open file.
Here we introduce is how to use the stream to read the data in the TXT file, and displayed in the specified display area. Let us first to understand the ReadBuffer method by a simple example, let's read the specified 10 characters before the TXT file.
Procedure TForm1.Button1Click (Sender: TObject);
Var
MyFile:TMemoryStream;
Filebuf: array[1..10] of char; / / here is a static array declaration
A:string;
Begin