|
-
Jun 24th, 2001, 03:05 AM
#1
kill or rmd
what command that could be to kill , delete or remove a path installed in floppy disk , please example needed
-
Jun 24th, 2001, 03:13 AM
#2
You can use the RmDir statement.

I should mention, the dircetory must be empty.
-
Jun 24th, 2001, 03:29 AM
#3
Registered User
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
-
Jun 25th, 2001, 02:53 AM
#4
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.
-
Jun 25th, 2001, 03:25 AM
#5
Registered User
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.
-
Jun 25th, 2001, 04:57 AM
#6
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
-
Jun 25th, 2001, 05:15 AM
#7
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
-
Jun 26th, 2001, 12:58 AM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|