Delete All Files In Directory


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



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.