acbs 发表于 2011-2-25 10:12:34

如何确定文件是否被使用

我有一个文件,如何判断某个时间这个文件是否被使用呢?谢谢。

smartzbs 发表于 2011-2-25 10:16:43

$sFileName = "test.txt"
$file = FileOpen($sFileName, 0)

; Check if file opened for reading OK
If $file = -1 and fileexists($sFileName) Then
    MsgBox(0, "Error", "文件无法打开(可能正被使用).")
EndIf

FileClose($file)

acbs 发表于 2011-2-25 11:27:04

$sFileName = "test.txt"
$file = FileOpen($sFileName, 0)

; Check if file opened for reading OK
I ...
smartzbs 发表于 2011-2-25 10:16 http://www.autoitx.com/images/common/back.gif
好像不行,打不开的错误提示只有文件不存在的情况下才会出
如果文件存在,就不会提示。
感谢您的关注。

boyhong 发表于 2011-2-28 16:56:03

试试用FileRecycle ( "源文件" )利用它的返回值试试呢?呵呵,另类之方法。。。

502762378 发表于 2011-3-1 02:44:32

看这个文件的进程name
判断进程是否存在?
定个计划任务
页: [1]
查看完整版本: 如何确定文件是否被使用