VB 判断当前目录文件是否存在?

[复制链接]
查看11 | 回复5 | 2018-3-31 03:44:21 | 显示全部楼层 |阅读模式
这可用下列语句进行判断 Dir([pathname],[Attributes as VbFileAttribute=vbNormal]) As String 解释: pathname:文件的绝对路径; Attributes:文件的属性。 “[]”内为可选项。dir(file)=""表示文件不存在,dir(file)""表示文件存在。 例如判断c:wpswinwps.exe是否存在,如存在,就调用它,可用下列语句: if dir("c:wpswinwps.exe")"" then shell "c:wpswinwps.exe" end if ...
回复

使用道具 举报

千问 | 2018-3-31 03:44:21 | 显示全部楼层
if dir(app.path & "\abc.txt")="" then'不存在else'存在end if...
回复

使用道具 举报

千问 | 2018-3-31 03:44:21 | 显示全部楼层
if dir(app.path & "\abc.txt")"" thenMsgBox app.path & "\abc.txt")""& "文件存在 "elseMsgBox app.path & "\abc.txt")""& "文件不存在 " end if...
回复

使用道具 举报

千问 | 2018-3-31 03:44:21 | 显示全部楼层
dir(你的文件路径)>0 表示文件存在,否则不存在...
回复

使用道具 举报

千问 | 2018-3-31 03:44:21 | 显示全部楼层
Dim fsoTest As New FileSystemObject If fsoTest.FolderExists(App.Path & "\abc.txt") = True Then
MsgBox "文件存在 " Else
MsgBox "不存在 " E...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行