Check Folder Directory Exists Using VB.NET


/ Published in: VB.NET
Save to your folder(s)

I came across a permission issue when using the standard Directory.Exists() method, so I came up with another way to check if a Directory exists avoiding those permission issues. This works very well. It can be converted to C'#.


Copy this code and paste it in your HTML
  1. Private Function DirectoryExists(ByVal sPath As String) As Boolean
  2.  
  3. Try
  4. If System.IO.Directory.GetDirectories(sPath).Length > 0 Then
  5. Return True
  6. End If
  7. Catch ex As Exception
  8. Return False
  9. End Try
  10.  
  11. Return False
  12.  
  13. End Function

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.