How can I execute File Operations using the Windows File Transfer Common Dialogs?

  • Thread starter Christian Blackburn
  • Start date
C

Christian Blackburn

Hi Gang,
I would like to have my program use the built in Move and Copy Dialogs that
are used by Windows Explorer/My Computer.
Thanks in Advance,
Christian Blackburn
 
C

Christian Blackburn

Hi Herfried,
Thanks for the examples however I couldn't get my implementation to work.
Have you any experience with this function? Perhaps you can tell what I'm
doing wrong.
Here's my code:
---------------------------
Module Shell_File_Operation

Private Structure FileOperationStructure

Dim hWnd As IntPtr

Dim Operation As FileOperation

Dim strSource As String

Dim strDestination As String

Dim Flags As ShellFlags

Dim Aborted As Boolean

Dim FileNameMappings As Integer

Dim strProgress As String

End Structure

Private Enum FileOperation As Integer

Move = &H1

Copy = &H2

Delete = &H3

Rename = &H4

End Enum

Private Enum ShellFlags As Short

MultipleDestinations = &H1

NoConfirmation = &H10

ConfirmOperation = &H2

SilentOperation = &H4

RenameOnCollision = &H8

UseFileNameMappings = &H20

End Enum

Private Declare Function SHFileOperation Lib "shell32" Alias
"SHFileOperationA" (ByVal FileOp As FileOperationStructure) As Integer

Public Sub ShellFileMove(ByVal strSource, ByVal strDestination)

Dim stcMove As FileOperationStructure

'stcMove.hWnd = objMain.Handle

'stcMove.Aborted = False

stcMove.strSource = strSource

'stcMove.strDestination = FilePath(strDestination) & "\"

stcMove.strDestination = strDestination

stcMove.Operation = FileOperation.Move

'stcMove.strProgress = "Test Progress String..."

stcMove.Flags = ShellFlags.NoConfirmation

SHFileOperation(stcMove)

End Sub

End Module
 
H

Herfried K. Wagner [MVP]

* "Christian Blackburn said:
Private Declare Function SHFileOperation Lib "shell32" Alias
"SHFileOperationA" (ByVal FileOp As FileOperationStructure) As Integer

I don't have enough time now to take a look at the definition of the
structure, but you can try to pass 'FileOp' 'ByRef' and remove the
function alias. Instead, you can declare the function as 'Auto'
('Declare Auto Function...').
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top