about vb

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nilesh3
    New Member
    • Nov 2008
    • 5

    about vb

    Hi,my question is how delete folder using vb
  • smartchap
    New Member
    • Dec 2007
    • 236

    #2
    With FileSystemObjec t and its .GetFolder and .Delete commands first you get the folder you want to delete in a variable then delete it.

    Comment

    • jg007
      Contributor
      • Mar 2008
      • 283

      #3
      or using System.IO.direc tory

      'directory.dele te' will delete an empty directory

      Comment

      • tropix100
        New Member
        • Nov 2008
        • 12

        #4
        Originally posted by jg007
        or using System.IO.direc tory

        'directory.dele te' will delete an empty directory
        The old way was to delete all the files from the directory and then delete the directory.
        Dhould the directory contasin sub directories, then you will need to recure through them to ensure all files are deleted and then delete the directory. If the directory contains files then you will recieve an error.

        Private Sub Form_Load()
        Dim MyDir As String
        On Error GoTo ErrHandler
        MyDir = "D:\Temp"
        Kill MyDir & "\" & "*.*"
        RmDir "D:\Temp"
        Exit Sub
        ErrHandler:
        MsgBox Err.Number & " " & Err.Description , vbOKCancel, "This is a program generated error"
        End Sub

        Comment

        Working...