dotnet-Snippets.com
Snippets: 57 | Registered User: 27 | Visitors online: 18
Main Menu

Home
Random Snippet
FAQs
Contact Us
Imprint
RSS Feeds

Rss All languages
Rss C#
Rss VB.NET
Rss C++
Rss J#
Rss ASP.NET
Google Ads

Sri Lanka .NET 
                Forum Member
Filecopy via Windows Shell Dialogue

Author: Tim Hartwig
Programming Language: VB.NET Rating:
not yet rated

Views: 842

Description:

With this function you can copy one or more files via windows shell dialogue. This means you will see the default copy progress dialogue when the files beeing copied.



Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer

Private Structure SHFILEOPSTRUCT
    Dim hwnd As Integer
    Dim wFunc As Integer
    Dim pFrom As String
    Dim pTo As String
    Dim fFlags As Short
    Dim fAnyOperationsAborted As Boolean
    Dim hNameMappings As Integer
    Dim lpszProgressTitle As String
End Structure

Const FO_COPY As Short = &H2S

Public Function ShellCopy(ByVal strSource As String, ByVal strTarget As String, ByVal Handle As Long) As Boolean
    Dim SFO As New SHFILEOPSTRUCT

    If Right(strSource, 1) = "\" Then strSource = Mid(strSource, 1, Len(strSource) - 1)
    ShellCopy = True
    With SFO
        .hwnd = Handle
        .wFunc = FO_COPY
        .pFrom = strSource & Chr(0) & Chr(0)
        .pTo = strTarget & Chr(0) & Chr(0)
    End With

    Call SHFileOperation(SFO)
    If SFO.fAnyOperationsAborted Then ShellCopy = False
End Function



Poor Excellent
1 2 3 4 5 6 7 8 9 10
Sign in to vote for this snippet.

Comments:
(Please log in to wrtite an comment.)