moonboor 发表于 2009-9-20 15:41:27

filereadline问题

$file = FileOpen("config.txt", 0)

If $file = -1 Then
    MsgBox(0, "错误", "不能打开文件.")
    Exit
EndIf


While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    MsgBox(0, "读取的行:", $line)
Wend

FileClose($file)

当前文件夹里有一个config.txt的文件。而且里面也有数据。但是就是读取不出来。请各位帮我看一看这是什么问题。

lpxx 发表于 2009-9-20 15:58:53

就把config.txt文件里写上以下代码读读看$file = FileOpen("config.txt", 0)

If $file = -1 Then
    MsgBox(0, "错误", "不能打开文件.")
    Exit
EndIf


While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    MsgBox(0, "读取的行:", $line)
Wend

FileClose($file)

moonboor 发表于 2009-9-20 16:09:25

这样也是不行的。提示“不能打开文件”

kn007 发表于 2009-9-20 17:13:08

我这里很正常,如果config.txt是空的,将会退出不提示什么,如果有一行字,他就会显示,,,


$file = FileOpen("config.txt", 0)

If $file = -1 Then
    MsgBox(0, "错误", "不能打开文件.")
    Exit
EndIf


While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    MsgBox(0, "读取的行:", $line)
Wend

FileClose($file)

水木子 发表于 2009-9-20 18:12:51

测试过楼主的代码,没问题,可以正常读取。

config.txt文件需和脚步一目录。

sunafter 发表于 2009-9-20 18:35:11

文件确保在脚本目录下
页: [1]
查看完整版本: filereadline问题