computer 版 (精华区)

发信人: windoe (为中国电信做贡献), 信区: program
标  题: VB:如何判断一个文件是否存在?
发信站: 听涛站 (Fri Mar 10 19:08:56 2000), 转信

可以通过打开该文件试图读取资料的方法实现,如果文件打开
成功,证明该文件存在;反之,文件就不存在。
Function FileExists(fname$) As Boolean
On Error Resume Next ’设置错误处理
Dim X as Integer
X = FreeFile ’取得一个空闲文件句柄
Open fname$ For Input As X ’试图打开该文件
If Err = 0 Then ’如果打开成功
FileExists = True
Else ’否则
FileExists = False
End If
Close X
End Function


--By Kammi's SuperPost General Version
--

夜中不能寐,起坐弹鸣琴。
    薄帷鉴明月,清风吹我襟。
孤鸿号外野,翔鸟鸣北林。
    徘徊将何见,忧思独伤心。


[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:1.543毫秒