Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

ellooow again

 

I have written some code to move a file to a certain directory with file.move. It would be nice if you could see the copy file animation of windows.

This is possible with the following API in older versions of vb but not in vb.net...

 

 

Public Type SHFILEOPSTRUCT

hWnd As Long

wFunc As Long

pFrom As String

pTo As String

fFlags As Integer

fAnyOperationsAborted As Long

hNameMappings As Long

lpszProgressTitle As Long ' only used if FOF_SIMPLEPROGRESS

End Type

Public Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

Public Const FO_COPY = &H2

Public Const FO_DELETE = &H3

Public Const FO_MOVE = &H1

Public Const FO_RENAME = &H4

Public Const FOF_ALLOWUNDO = &H40

Public Const FOF_NOCONFIRMATION = &H10 ' No Confirmation

Public Const FOF_NOCONFIRMMKDIR = &H200

Public Const FOF_SIMPLEPROGRESS = &H100

 

 

 

Is there an alternative for this animation in vb.net? I know that in .net the long must be changed in integer because of the 32-bit range

but that doesn't help me any further

 

thx greets koen

  • Leaders
Posted

here's a quick example i knocked up for you ...

   Public Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer

   Public Enum FO_FLAGS As Integer
       FO_COPY = &H2
       FO_DELETE = &H3
       FO_MOVE = &H1
   End Enum

   <System.Runtime.InteropServices.StructLayout( _
   System.Runtime.InteropServices.LayoutKind.Sequential)> _
   Public Structure SHFILEOPSTRUCT
       Public hWnd As Integer
       Public wFunc As FO_FLAGS
       Public pFrom As String
       Public pTo As String
       Public fFlags As Integer
       Public fAborted As Integer
       Public hNameMaps As Integer
       Public sProgress As String
   End Structure

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim shStruct As New SHFILEOPSTRUCT
       With shStruct
           .pFrom = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
           .pTo = "F:\test_folder"
           .wFunc = FO_FLAGS.FO_COPY
       End With

       SHFileOperation(shStruct)
   End Sub

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...