delphi读取服务器txt文件,delphi 用流来读取txt文件(Delphi reads the txt file with the stream).doc...

这篇博客介绍了如何在Delphi中利用流(Stream)来读取TXT文件的内容。通过创建TextFile指针,使用AssignFile方法关联TXT文件,然后通过Reset、Rewrite或Append方式初始化读写操作。ReadBuffer方法被用来读取指定数量的字符。最后,使用CloseFile关闭文件。文章以一个简单的例子展示了如何读取TXT文件前10个字符。
摘要由CSDN通过智能技术生成

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值