Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
This code shows how to delete a file by moving it ...
Author:
Luther W. Early
Submitted:
5/5/2000
Version:
VB5
Compatibility:
VB5, VB6
Category:
Windows API
Views:
10073
This code shows how to delete a file by moving it to the recycle bin.
Declarations:
Public 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 Public Const FO_DELETE As Long = &H3 Public Const FOF_NOCONFIRMATION As Long = &H10 Public Const FOF_ALLOWUNDO As Long = &H40 Public Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Code:
'Returns True if successful Public Function Erase2RecycleBin(fileSpec$) As Boolean Dim SHFileOp As SHFILEOPSTRUCT With SHFileOp .wFunc = FO_DELETE .pFrom = fileSpec$ & vbNullChar .fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION End With Erase2RecycleBin = (SHFileOperation(SHFileOp) = 0) End Function 'Call the function like this: blnSuccess = Erase2RecycleBin("C:\Myfolder\myfile")
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement