请问如何获得一个文件的状态,如是否被其它程序运行?

maculasoft 2004-01-07 05:28:03
请问如何获得一个文件的状态,如是否被其它程序运行?因为我在程序中要删除一个文件,但当这个文件在运行的时候就不能删除了,所以我想在事先的时候就获得这个文件的状态,请问如何获得?
...全文
23 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
maculasoft 2004-01-08
  • 打赏
  • 举报
回复
二位到另一个帖子接分
3661512 2004-01-07
  • 打赏
  • 举报
回复
参考
http://www.china-askpro.com/msg6/qa35.shtml
Sean918 2004-01-07
  • 打赏
  • 举报
回复
sorry~~~~ errors...

=============================
''try :

private sub ...
if FileInUse("file name") then
msgbox "File is in use!"
else
...
end if
end sub

Public Function FileInUse(path$) As Boolean
Dim X
X = FreeFile ''''get free file #

On Error Resume Next
Open path$ For Input As X
If err = 0 Then
FileInUse= True
Else
FileInUse= False
End If

Close X

End Function

Sean918 2004-01-07
  • 打赏
  • 举报
回复
''try:
private sub ...
if FileInUse("file name") then
msgbox "File is in use!"
else
...
end if
end sub

Public Function FileInUse(path$) As Boolean
Dim X
X = FreeFile ''''get free file #

On Error Resume Next
Open path$ For Input As X
If err = 0 Then
FileExists = True
Else
FileExists = False
End If

Close X

End Function

maculasoft 2004-01-07
  • 打赏
  • 举报
回复
解决另加分送上

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧