加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

VB.Net判断目录或文件是否存在的实例

发布时间:2020-12-16 23:21:06 所属栏目:大数据 来源:网络整理
导读:Imports System.IO Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load If Boo_DirExist("C:/Lob.cn/") Then MsgBox("存在C:/Lob.cn/目录") Else MsgBox("不存在C:/Lob.cn/目录")

Imports System.IO

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load

If Boo_DirExist("C:/Lob.cn/") Then
MsgBox("存在C:/Lob.cn/目录")
Else
MsgBox("不存在C:/Lob.cn/目录")
End If
If Boo_FileExist("C:/Lob.txt") Then
MsgBox("存在C:/Lob.txt文件")
Else
MsgBox("不存在C:/Lob.txt文件")
End If

End Sub

'判断目录是否存在的函数 传入String值 返回Boolean值

Private Function Boo_DirExist(ByVal Str_Path As String) As Boolean

Boo_DirExist = System.IO.Directory.Exists(Str_Path)

End Function

'判断文件是否存在的函数 传入String值 返回Boolean值

Private Function Boo_FileExist(ByVal Str_File As String) As Boolean

Boo_FileExist = System.IO.File.Exists(Str_File)

End Function

End Class

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读