Results 1 to 8 of 8

Thread: kill or rmd

  1. #1
    dana340
    Guest

    Talking kill or rmd

    what command that could be to kill , delete or remove a path installed in floppy disk , please example needed

  2. #2
    sunnyl
    Guest
    You can use the RmDir statement.

    VB Code:
    1. RmDir "c:\windows"




    I should mention, the dircetory must be empty.

  3. #3
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    Or to delete a directory including subdirectories and optionally send to the recycle bin:

    In Module:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Type SHFILEOPSTRUCT
    4.     hWnd As Long
    5.     wFunc As Long
    6.     pFrom As String
    7.     pTo As String
    8.     fFlags As Integer
    9.     fAborted As Boolean
    10.     hNameMaps As Long
    11.     sProgress As String
    12. End Type
    13.  
    14. Private Const FOF_NOCONFIRMATION = &H10
    15. Private Const FO_DELETE = &H3
    16. Private Const FOF_ALLOWUNDO = &H40
    17. Private Const FOF_FILESONLY = &H80                 '  On *.*, Do only files
    18.  
    19. Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
    20.  
    21. Public Function NuKill(Path As String, Optional Recycle As Boolean = True) As Boolean
    22.  'Nucleus
    23.  'Delete file(s) Or Folder(s) (including subdirectories) And optionally send To recycle bin
    24.  'In: Path of file/folder
    25.  'Out: Boolean indicating success
    26.  
    27.  If Right(Path, 1) = "\" Then Path = Left(Path, Len(Path) - 1)
    28.  If Len(Dir$(Path)) <> 0 Or Len(Dir$(Path, vbDirectory)) <> 0 Then
    29.     Dim SHFileOp As SHFILEOPSTRUCT
    30.     With SHFileOp
    31.         'Delete the file
    32.         .wFunc = FO_DELETE
    33.         'Select the file
    34.         .pFrom = Path
    35.         .fFlags = FOF_NOCONFIRMATION Or FOF_FILESONLY
    36.        
    37.         'next optionally allow move To recycle bin
    38.         'which only works For whole folders Or single file operations
    39.         'it will Not send *.* Or *.txt To recycle bin
    40.         'due To built-in limitations In api Function
    41.         If Recycle Then .fFlags = .fFlags Or FOF_ALLOWUNDO
    42.     End With
    43.     'perform file operation
    44.     NuKill = (SHFileOperation(SHFileOp) = 0)
    45.  End If
    46. End Function


    Usage:
    VB Code:
    1. Private Sub Command1_Click()
    2. 'NuKill "c:\tmp\book1.xls" 'delete Single file And send To recycle bin
    3. MsgBox NuKill("c:\tmp")  'delete folder And send To recycle bin
    4. 'NuKill "c:\temp",false" 'delete folder, don't send To recyle bin
    5.  
    6. 'Next the limitations:
    7. 'Note you can use kill\*.* instead for single directory operations
    8. 'NuKill "c:\tmp\*" ' delete all files In folder can't send To recycle bin due To api Function limitation
    9. 'NuKill "c:\tmp\*.txt" ' delete all text files In folder, can't send To recyle bin due To api Function limitations
    10. End Sub

  4. #4
    dana340
    Guest

    Angry kill or rmd

    sir :
    to tray the example
    i have create dir. as temp & path as pass
    in floppy disk
    then
    i have copyed the option in module as
    Option Explicit
    Private Type SHFILEOPSTRUCT
    HWND As Long
    WFUNC As Long
    PFORM As String
    PTO As String
    FFLAGS As Integer
    FABORTED As Boolean
    HNAMEMAPS As Long
    SPROGRESS As String
    End Type
    Private Const FOF_NOCOFIRMATION = &H10

    Private Const FO_DELETE = &H3
    Private Const FOF_ALLOWUNDO = &H40
    Private Const FOF_FILESONLY = &H80

    Private Declare Function SHFILEOPERATION Lib "SHELL32.DLL" Alias "SHFILEOPERATIONA" ()
    Public Function NUKILL(PATH As String, Optional RECYCLE As Boolean = True) As Boolean
    If Right(PATH, 1) = "\" Then PATH = Left(PATH, Len(PATH) - 1)
    IF LEN (DIR$(PATH)<> 0 OR LEN(DIR$(PATH,VBDIRECTOE )) <> 0THEN

    Dim SHFILEOP As SHFILEOPSTRUCT
    With SHFILEOP
    WFUNC = FO_DELETE
    .PFORM = PATH
    .FFLAGS = FOF_NOCONFIRMATION Or FOF_FILESONLY

    If RECYCLE Then
    .FFLAGS = .FFLAGS Or FOF_ALLOWUNDO
    End With
    NUKILL = (SHFILEOPERATION(SHFILEOP) = 0)
    End If
    End Function

    '***********
    then i have create button as

    Private Sub Command1_Click()
    MsgBox NUKILL("A:\TEMP\*", False)

    End Sub
    i have error msg , i know i have don something stupid
    please sill need your help
    thank you in advance.



  5. #5
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    You haven't copied the function properly, this line now contains errors:

    IF LEN (DIR$(PATH)<> 0 OR LEN(DIR$(PATH,VBDIRECTOE )) <> 0THEN

    Copy the code again, and this time don't change anything until you get it working. Good luck.

  6. #6
    dana340
    Guest

    kill or rmd

    sir:
    i have copied the function properly, but this line still contains compile errors msg:

    IF LEN (DIR$(PATH)<> 0 OR LEN(DIR$(PATH,VBDIRECTOE )) <>0THEN

    command1
    Private Sub Command1_Click()

    MsgBox NUKILL("c:\tmp")
    End Sub
    as the example without change




  7. #7
    sunnyl
    Guest
    You should copy and paste the code Nucleus posted to avoid typos...

    VB Code:
    1. If Len(Dir$(Path)) <> 0 Or Len(Dir$(Path, vbDirectory)) <> 0 Then

  8. #8
    dana340
    Guest

    Wink kill or rmd

    sir:

    i have don the example , and that was grateful

    thank you for your patient and help

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