Results 1 to 4 of 4

Thread: File Manipulation With Progress Bar (Move, Copy, Delete, Read, Write, etc)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    File Manipulation With Progress Bar (Move, Copy, Delete, Read, Write, etc)

    Basically lets say my application needs to read a file or it needs to copy files around, move them etc... How can I link this with a progress bar to graphically display the "progress" of the operation?
    Visual Basic Rules!!!!!

  2. #2
    Fanatic Member
    Join Date
    Feb 2001
    Posts
    759

    Re: File Manipulation With Progress Bar (Move, Copy, Delete, Read, Write, etc)

    Get the file size of the file using the FileLen() command. Then set the max length of the progress bar to the FileLen() file size. As the file is moved or copied adjust the progress bar accordingly.

  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: File Manipulation With Progress Bar (Move, Copy, Delete, Read, Write, etc)

    Another option you have to use an Avi file while an operation is going on, that would be much simplier that using progress bar for those tasks...

    Or that there is already a method of showing an animation while a file copy is in progress...

    Code:
    'Module:
    Option Explicit 
    
    Private Type SHFILEOPSTRUCT
        hWnd As Long
        wFunc As Long
        pFrom As String
        pTo As String
        fFlags As Integer
        fAnyOperationsAborted As Boolean
        hNameMappings As Long
        lpszProgressTitle As String
    End Type
    
    Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
    
    Private Const FO_COPY = &H2
    Private Const FOF_ALLOWUNDO = &H40
    
    Public Sub SHCopyFile(ByVal from_file As String, ByVal to_file As String)
    Dim sh_op As SHFILEOPSTRUCT
    
        With sh_op
            .hWnd = 0
            .wFunc = FO_COPY
            .pFrom = from_file & vbNullChar & vbNullChar
            .pTo = to_file & vbNullChar & vbNullChar
            .fFlags = FOF_ALLOWUNDO
        End With
    
        SHFileOperation sh_op
    End Sub
    
    'Form
    Private Sub Command1_Click()
    'the following line will copy the file "d:\file.zip" to "d:\temp\file2.zip"
        SHCopyFile "c:\dee-u.zip", "d:\dee-u.zip"
    End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: File Manipulation With Progress Bar (Move, Copy, Delete, Read, Write, etc)

    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width