前端之家收集整理的这篇文章主要介绍了
VB.NET 判断文件夹目录与文件是否存在检查,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Private@H_502_6@SubBTN_LOAD_Click(@H_502_6@ByValsender@H_502_6@AsSystem.Object,@H_502_6@ByVale@H_502_6@AsSystem.EventArgs)@H_502_6@HandlesBTN_LOAD.Click
'文件夹 CHECK
@H_502_6@If@H_502_6@NotblnDirExist(TXT_PATH.Text.Trim)@H_502_6@Then
MsgBox("文件夹路径不存在")
BTN_LOAD.Focus()
@H_502_6@Exit@H_502_6@Sub
@H_502_6@End@H_502_6@If
'文件 CHECK
@H_502_6@If@H_502_6@NotblnFileExist(TXT_PATH.Text.Trim)@H_502_6@Then
MsgBox("文件不存在")
BTN_LOAD.Focus()
@H_502_6@Exit@H_502_6@Sub
@H_502_6@End@H_502_6@If
End@H_502_6@Sub
#@H_502_6@Region"文件夹存在CHECK"
@H_502_6@Private@H_502_6@FunctionblnDirExist (@H_502_6@ByValstrPath@H_502_6@As@H_502_6@String)@H_502_6@As@H_502_6@Boolean
DimstrDirTemp@H_502_6@As@H_502_6@String()
strDirTemp = strPath.Split("\")
strPath =@H_502_6@String.Empty
@H_502_6@Fori@H_502_6@As@H_502_6@Integer= 0@H_502_6@TostrDirTemp.Length – 2
strPath += strDirTemp(i) &"\"
@H_502_6@Next
blnDirExist = System.IO.Directory.Exists(strPath)
@H_502_6@End@H_502_6@Function
#End Region
#@H_502_6@Region"文件存在CHECK"
@H_502_6@Private@H_502_6@FunctionblnFileExist (@H_502_6@ByValstrFile@H_502_6@As@H_502_6@String)@H_502_6@As@H_502_6@Boolean
blnFileExist = System.IO.File.Exists(strFile)
@H_502_6@End@H_502_6@Function #End Region