Option Explicit
Private Declare Function SHFileOperationStr Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCTStr) As Long
Private Type SHFILEOPSTRUCTStr
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String
End Type
Public Enum Enum_FOFunc
FO_MOVE = 1
FO_Copy = 2
FO_DELETE = 3
FO_RENAME = 4
End Enum
Public Enum Enum_FOFlags
FOF_MULTIDESTFILES = &H1
FOF_CONFIRMMOUSE = &H2
FOF_SILENT = &H4
FOF_RENAMEONCOLLISION = &H8
FOF_NoConfirmation = &H10
FOF_WANTMAPPINGHANDLE = &H20
FOF_ALLOWUNDO = &H40
FOF_FILESONLY = &H80
FOF_SIMPLEPROGRESS = &H100
FOF_NOCONFIRMMKDIR = &H200
FOF_DeleteFlags = &H154
FOF_CopyFlags = &H3DD
End Enum
'----------------------------------------------------------------------------------------------
'DoFileOp returns true or false depending on success of the operation.
'Dim rslt As Boolean
'
'Copy a file with a prompt if the file is going to overwrite an existing file.
'rslt = DoFileOp(FO_Copy, "C:\Test.txt", "C:\Temp\Test.txt", FOF_CONFIRMMOUSE Or FOF_CopyFlags)
'
'Delete a file and send it to the recycle bin with a prompt to confirm deletion.
'DoFileOp(FO_DELETE, "C:\Test.txt", , FOF_CONFIRMMOUSE Or FOF_ALLOWUNDO)
'
'Delete a Folder and send it to the recycle bin without a prompt.
'DoFileOp(FO_DELETE, "C:\Test.txt", , FOF_NoConfirmation Or FOF_ALLOWUNDO)
'----------------------------------------------------------------------------------------------
'
Public Function DoFileOp(Operation As Enum_FOFunc, sFrom As String, _
Optional sTo As String = vbNullString, _
Optional FLAGS As Enum_FOFlags, _
Optional SimpleProgressTitle As String = "Restoring. Please Wait...", _
Optional hwnd As Long) As Boolean
Dim SHFOS As SHFILEOPSTRUCTStr
' On Error GoTo DoFileOp_Error
With SHFOS
.hwnd = hwnd
.pFrom = sFrom
.pTo = sTo
.wFunc = Operation
.fFlags = FLAGS
.lpszProgressTitle = SimpleProgressTitle
End With
SHFileOperationStr SHFOS
If SHFOS.fAnyOperationsAborted Then
DoFileOp = False
Else
DoFileOp = True
End If
' On Error GoTo 0
' Exit Function
'DoFileOp_Error: pPrintError "DoFileOp"
End Function
'-----------------END HERE------------------
To All...Mau tanya nih... coding untuk rename file gimana ya? kemarin sempat cari di MSDN harus buat function sendiri buat rename. ada yang bisa berikan functionnya? makasih ya....-Petry-
Wahana Programmer Groups Links
<*> Untuk mengunjungi sponsor milis ini, klik link berikut:
http://wahanaprogrammer.net
<*> Untuk menghubungi owner milis ini, kirim email ke:
[EMAIL PROTECTED]
<*> Konsultasi pemrogramman bisa chat disini:
Yahoo! Messenger: wahanaprogrammer
| Programmer | Indonesia | Basic programming language |
| Computer programming languages | Programming languages | Java programming language |
YAHOO! GROUPS LINKS
- Visit your group "Programmer-VB" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
