微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

原文地址:https://www.jb51.cc/vb/262583.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐