前端之家收集整理的这篇文章主要介绍了
VB.NET 判断文件夹目录与文件是否存在检查,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PrivateSubBTN_LOAD_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesBTN_LOAD.Click@H_502_18@ '文件夹 CHECK@H_502_18@ IfNotblnDirExist(TXT_PATH.Text.Trim)Then@H_502_18@ MsgBox("文件夹路径不存在")@H_502_18@ BTN_LOAD.Focus()@H_502_18@ ExitSub@H_502_18@ EndIf@H_502_18@ '文件 CHECK@H_502_18@ IfNotblnFileExist(TXT_PATH.Text.Trim)Then@H_502_18@ MsgBox("文件不存在")@H_502_18@ BTN_LOAD.Focus()@H_502_18@ ExitSub@H_502_18@ EndIf@H_502_18@ EndSub@H_502_18@ @H_502_18@ #Region"文件夹存在CHECK"@H_502_18@ PrivateFunctionblnDirExist (ByValstrPathAsString)AsBoolean@H_502_18@ DimstrDirTempAsString()@H_502_18@ strDirTemp = strPath.Split("\")@H_502_18@ strPath =String.Empty@H_502_18@ ForiAsInteger= 0TostrDirTemp.Length – 2@H_502_18@ strPath += strDirTemp(i) &"\"@H_502_18@ Next
blnDirExist = System.IO.Directory.Exists(strPath)@H_502_18@ EndFunction@H_502_18@ #End Region@H_502_18@ @H_502_18@ #Region"文件存在CHECK"@H_502_18@ PrivateFunctionblnFileExist (ByValstrFileAsString)AsBoolean@H_502_18@ blnFileExist = System.IO.File.Exists(strFile)@H_502_18@ EndFunction #End Region