![]() |
#2
sdta2021-04-28 20:46
|
Local gnFileHandle,nSize,cString
gnFileHandle = FOPEN("D:\kejian\file_s\sd.txt")
* Seek to end of file to determine number of bytes in the file.
nSize = FSEEK(gnFileHandle, 0, 2) && 移动指针到末尾
IF nSize <= 0
* If file is empty, display an error message.
WAIT WINDOW "This file is empty!" NOWAIT
ELSE
* If file is not empty, store the file's contents in memory
* and display the text in the main Visual FoxPro window.
= FSEEK(gnFileHandle, 0, 0) && 移动指针到开始
cString = FREAD(gnFileHandle, nSize)
=FWRITE(gnFileHandle, "abcd" )
ENDIF
= FCLOSE(gnFileHandle) && 关闭文件
[此贴子已经被作者于2021-4-28 20:24编辑过]