VB.Net判断目录或文件是否存在的方法

乐博网系列初学者实例 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.cnblogs.com/nieyj/archive/2010/12/23/1914723.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值