|
-
Dec 9th, 2001, 02:08 PM
#1
Thread Starter
Junior Member
Sending Files to the Recycle Bin?!?!?
Hey guys... i am stuck trying to creat a command or searching for one which will be able to send any file to the recycle bin.. from what i learned the recycle bin is some kind of virtual file... but i dont understand the concept given in the MSDN library about it.. i wounder if there is a built in function or do i need to create it... and if i have to create it.. what do i need to know... for such operation???
Artist get ofended by bad Art, I get ofended by bad programming... 
-
Dec 9th, 2001, 02:14 PM
#2
PowerPoster
VB Code:
'This program needs a Common Dialog Box, named CDBox.
' (To add the Common Dialog Box to your tools menu, go to Project->Components (or press CTRL-T)
' and select Microsoft Common Dialog control)
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 FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Sub Form_Load()
Dim SHFileOp As SHFILEOPSTRUCT
'Set the dialog's title
CDBox.DialogTitle = "Select a file to delete ..."
'Set the dialog's filter
CDBox.Filter = "All Files (*.*)|*.*"
'Show the 'Open File' dialog
CDBox.ShowOpen
With SHFileOp
'Delete the file
.wFunc = FO_DELETE
'Select the file
.pFrom = CDBox.filename
'Allow 'move to recycle bn'
.fFlags = FOF_ALLOWUNDO
End With
'perform file operation
SHFileOperation SHFileOp
MsgBox "The file '" + CDBox.filename + "' has been moved to your Recycling Bin !", vbInformation + vbOKOnly, App.Title
End Sub
-
Dec 9th, 2001, 02:20 PM
#3
Thread Starter
Junior Member
thanx... =:O)
Thank you dude... been trying to do this for the past 2weeks....
Thanx alot.... =:OD
Artist get ofended by bad Art, I get ofended by bad programming... 
-
Dec 9th, 2001, 02:22 PM
#4
-= B u g S l a y e r =-
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 FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Sub Command1_Click()
Dim sFile2Delete As String
'file to delete
sFile2Delete = "C:\TEST.BMP"
'doit
ShellDeleteFile sFile2Delete, FOF_ALLOWUNDO
End Sub
Public Sub ShellDeleteFile(sFile As String, ActionFlag As Long)
Dim SHFileOp As SHFILEOPSTRUCT
Dim r As Long
sFile = sFile & Chr$(0)
With SHFileOp
.wFunc = FO_DELETE
.pFrom = sFile
.fFlags = ActionFlag
End With
r = SHFileOperation(SHFileOp)
End Sub
-
Dec 9th, 2001, 02:23 PM
#5
PowerPoster
what you playing at peet?!
-
Dec 9th, 2001, 02:23 PM
#6
-= B u g S l a y e r =-
ouch!
"King of Most things..." have already been here
-
Dec 9th, 2001, 02:24 PM
#7
PowerPoster
-
Dec 9th, 2001, 02:25 PM
#8
Thread Starter
Junior Member
thanx again...
Thanx again... =:O)
Anychance having a smaller code... just kidding.... =:OP
Artist get ofended by bad Art, I get ofended by bad programming... 
-
Dec 9th, 2001, 05:52 PM
#9
Fanatic Member
how can i send a file to the recycle bin without asking for confirmation?
FlameWave Technologies - internet tools
-
Dec 9th, 2001, 06:04 PM
#10
-= B u g S l a y e r =-
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 FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_NOCONFIRMATION As Long = &H10
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Sub Command1_Click()
Dim sFile2Delete As String
'file to delete
sFile2Delete = "C:\TEST.BMP"
'doit
ShellDeleteFile sFile2Delete, FOF_ALLOWUNDO + FOF_NOCONFIRMATION
End Sub
Public Sub ShellDeleteFile(sFile As String, ActionFlag As Long)
Dim SHFileOp As SHFILEOPSTRUCT
Dim r As Long
sFile = sFile & Chr$(0)
With SHFileOp
.wFunc = FO_DELETE
.pFrom = sFile
.fFlags = ActionFlag
End With
r = SHFileOperation(SHFileOp)
End Sub
-
Dec 9th, 2001, 06:09 PM
#11
Fanatic Member
FlameWave Technologies - internet tools
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
|