what command that could be to kill , delete or remove a path installed in floppy disk , please example needed:D
Printable View
what command that could be to kill , delete or remove a path installed in floppy disk , please example needed:D
You can use the RmDir statement.
VB Code:
RmDir "c:\windows"
:D
I should mention, the dircetory must be empty.
Or to delete a directory including subdirectories and optionally send to the recycle bin:
In Module:
VB Code:
Option Explicit Private Type SHFILEOPSTRUCT hWnd As Long wFunc As Long pFrom As String pTo As String fFlags As Integer fAborted As Boolean hNameMaps As Long sProgress As String End Type Private Const FOF_NOCONFIRMATION = &H10 Private Const FO_DELETE = &H3 Private Const FOF_ALLOWUNDO = &H40 Private Const FOF_FILESONLY = &H80 ' On *.*, Do only files Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long Public Function NuKill(Path As String, Optional Recycle As Boolean = True) As Boolean 'Nucleus 'Delete file(s) Or Folder(s) (including subdirectories) And optionally send To recycle bin 'In: Path of file/folder 'Out: Boolean indicating success If Right(Path, 1) = "\" Then Path = Left(Path, Len(Path) - 1) If Len(Dir$(Path)) <> 0 Or Len(Dir$(Path, vbDirectory)) <> 0 Then Dim SHFileOp As SHFILEOPSTRUCT With SHFileOp 'Delete the file .wFunc = FO_DELETE 'Select the file .pFrom = Path .fFlags = FOF_NOCONFIRMATION Or FOF_FILESONLY 'next optionally allow move To recycle bin 'which only works For whole folders Or single file operations 'it will Not send *.* Or *.txt To recycle bin 'due To built-in limitations In api Function If Recycle Then .fFlags = .fFlags Or FOF_ALLOWUNDO End With 'perform file operation NuKill = (SHFileOperation(SHFileOp) = 0) End If End Function
Usage:
VB Code:
Private Sub Command1_Click() 'NuKill "c:\tmp\book1.xls" 'delete Single file And send To recycle bin MsgBox NuKill("c:\tmp") 'delete folder And send To recycle bin 'NuKill "c:\temp",false" 'delete folder, don't send To recyle bin 'Next the limitations: 'Note you can use kill\*.* instead for single directory operations 'NuKill "c:\tmp\*" ' delete all files In folder can't send To recycle bin due To api Function limitation 'NuKill "c:\tmp\*.txt" ' delete all text files In folder, can't send To recyle bin due To api Function limitations End Sub
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.
:mad:
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.
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
:confused:
You should copy and paste the code Nucleus posted to avoid typos...
VB Code:
If Len(Dir$(Path)) <> 0 Or Len(Dir$(Path, vbDirectory)) <> 0 Then
sir:
i have don the example , and that was grateful
thank you for your patient and help
;)