Results 1 to 5 of 5

Thread: Kill Kill kill

  1. #1

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    Can I not delete a directory using the kill command?
    Code:
    Kill ("C:\Windows\Desktop\Myfolder\")
    I have also tried
    Code:
    Kill ("C:\Windows\Desktop\Myfolder")
    and
    Code:
    Kill "C:\Windows\Desktop\Myfolder"
    and
    Code:
    Kill "C:\Windows\Desktop\Myfolder\"
    none work...which one am I missing?
    That arranged can be

  2. #2
    Lively Member
    Join Date
    Apr 2000
    Posts
    110

    Wink Try this...

    To create a folder you use the MKDir function:
    Code:
    'Create a folder
    MkDir "C:\MyFolder"
    To delete a folder, use the RmDir function:
    Code:
    'Delete a folder
    RmDir "C:\MyFolder"
    When creating a directory, if the directory all ready exists, then you will get an error. If you try to delete a folder that contains files, or sub-directories with files, then an error will also occur.

    Hope you know what I mean. Use the kill method for files only.

    Laterz

    REM
    "Innovate, don't immitate."

  3. #3

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    thanks ...got it
    That arranged can be

  4. #4

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    For some reason it will not delete the folder, I am thinking its because there are files in it...so I tried to kill the files before but
    kill "c:\myprogram\*.*"
    Doesnt work...
    That arranged can be

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    If you're using VB6 then set a reference to the Microsoft Scripting Runtime. Declare a FileSystemObject and call the DeleteFolder method. This method deletes a folder even if it contain files.
    Code:
    Private Sub KillFolder(sPath as String, Optional blnForce As Boolean)
        Dim fso As FileSystemObject
        Set fso = New FileSystemObject
        fso.DeleteFolder sPath, blnForce
    End Sub
    The blnForce value forces a delete even if the folder is ReadOnly.

    Good luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width