使用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.
结果发现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:关闭文件