Hi there, how about a close cousin to yesterdays Visual Basic function? In a previous post we showed you a function that will tell you whether or not a file does indeed exist. Well, here is another similar function, but it tells you whether or not a directory exists. This is another handy tool for all you code monkeys out there. It works much the same way, check it out below:
Public Function fDirExists(ByVal DirName As String) As Boolean Dim TempAttr As Integer On Error GoTo ErrorDirExist TempAttr = GetAttr(DirName) fDirExists = TempAttr GoTo ExitDirExist ErrorDirExist: fDirExists = False Resume ExitDirExist ExitDirExist: On Error GoTo 0 End Function
Does that look familiar?? It should! OK, you call it just like the other one, here take a look:
if fDirExists("c:\windows") then ' Hey, it's there else ' Nope, not there end if
Pretty simple, it returns true or false and lets you make informed decisions in your code. Keep up the hacking kiddies!








