DELPHI文件操作建议(reset打开只读文件处理)

 使用reset打开只读文件,发现会出错,导致数据不准,查了下帮助,发现

In Delphi code, Reset opens the existing external file with the name assigned to F using the mode specified by the global FileMode variable. An error results if no existing external file of the given name exists or if the file can't be opened with the current file mode. If F is already open, it is first closed and then reopened. The current file position is set to the beginning of the file.

Warning: The default value of FileMode is 2 ( Read/ Write access). If this is not changed to a read-only file mode before calling Reset, attempts to open read-only files will fail.

结果发现fileMode居然是sysutils的全局变量,悲剧呀;想修改fileMode的值再改回去,查帮助发现FileMode 居然不支持线程;

Warning: FileMode is declared as a variable, not as a threadvar. Therefore this variable is not thread-safe.

 

因此,建议delphi的用户们使用以下为文件函数操作:

1)fileOpen/FileCreate:打开/创建文件

2)fileSeek:移动文件

3)fileRead/fileWrite:读文件

4)fileClose:关闭文件

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值