Posted By

krlogin11 on 07/31/10


Tagged


Versions (?)

Delete All Files In Directory


 / Published in: VB.NET
 

  1. Public Shared Sub EmptyDirectory(ByVal _dirPath As String)
  2. If Not Directory.Exists(_dirPath) Then
  3. Return
  4. End If
  5. Dim files() As String
  6. files = Directory.GetFileSystemEntries(_dirPath)
  7. For Each element As String In files
  8. 'Do not clear sub directories
  9. If (Not Directory.Exists(element)) Then
  10. DeleteFile(Path.Combine(_dirPath, Path.GetFileName(element)))
  11. End If
  12. Next
  13. End Sub

Report this snippet  

You need to login to post a comment.