Results 1 to 13 of 13

Thread: Copy Folder And Progress Bar (vb6)

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Location
    Greece
    Posts
    4

    Post Copy Folder And Progress Bar (vb6)

    (excuse me if i posted on the wrong section)
    hallo, i'm new on visual basic and i wish for your help
    i want to copy a large folder(about 3 gigas)with many subfolders in it and files like read-only, hidden etc. to another folder with 1 button in the form for the procedure to start and a progress bar to show the progress of the copy.
    how can i do this?is there any example of code or a project available?
    thanks a lot

  2. #2
    Addicted Member Vanasha's Avatar
    Join Date
    Jun 2007
    Location
    In a bin.>_>
    Posts
    152

    Re: Copy Folder And Progress Bar (vb6)

    Take a look at the file system object. It can copy files etc.
    Quote Originally Posted by Vanasha
    Sorry, i'm slow.


  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Location
    Greece
    Posts
    4

    Re: Copy Folder And Progress Bar (vb6)

    @vanasha what about a progress bar?

  4. #4
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Copy Folder And Progress Bar (vb6)

    Use the progress bar control. Press Ctl+t -> Microsoft Windows Common control 6.0 (sp6)

  5. #5
    Lively Member Dazzler's Avatar
    Join Date
    Sep 2007
    Posts
    68

    Re: Copy Folder And Progress Bar (vb6)

    hi,

    If u can count the number of files your abt to copy, then set the max value of progress bar to that count and increase it one by one until it reaches its max value and make its visible false once it reached...

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Copy Folder And Progress Bar (vb6)

    See Post #2 in this thread. Is this what you are looking for?

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Location
    Greece
    Posts
    4

    Re: Copy Folder And Progress Bar (vb6)


    i'm looking for something like this, but not for a specific file,for an entire and specific folder (for example D:\source to D:\destination) with random number of files in it and random number of subfolders in it.with progress bar embeeded in the form not like a pop-up of windows
    Last edited by Yoshi-gr; Oct 2nd, 2007 at 03:05 AM.

  8. #8

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Location
    Greece
    Posts
    4

    Re: Copy Folder And Progress Bar (vb6)

    i found this for an instant file count
    vb Code:
    1. Dim fso As Scripting.FileSystemObject
    2. Set fso = New FileSystemObject
    3. Debug.Print fso.GetFolder("D:\source").Files.Count
    4. Set fso = Nothing
    (when i run this alone it shows me the error :invalid outside procedure for line 2)
    and then in the PBar
    vb Code:
    1. pbar.max = NumberOfFiles
    2. pbar.value = pbar.value + 1
    now how can i set theese things up in my form?
    where can i put a start button to start the copy?
    and what is happening to the subfolders?are theese files in them counted too?
    sorry for being so newbie but can someone give me some instructions?
    Last edited by Yoshi-gr; Oct 1st, 2007 at 06:54 AM.

  9. #9
    Addicted Member Vanasha's Avatar
    Join Date
    Jun 2007
    Location
    In a bin.>_>
    Posts
    152

    Re: Copy Folder And Progress Bar (vb6)

    Quote Originally Posted by Code Doc
    This may be too simple of a solution for you:
    Code:
    Dim NameFile As String, MyDirectory As String
    Private Sub Form_Load()
    MyDirectory = "C:\" ' Directory name goes here instead of the C drive root 
    NameFile = Dir$(MyDirectory)
    List1.AddItem NameFile
    While NameFile <> ""
        NameFile = Dir$
        List1.AddItem NameFile
    Wend
    End Sub
    All the file names in MyDirectory are now in the listbox.
    You could use the code above and the fso/FileCopy to copy all the files from independanty.
    Code:
    Destination = "C:\Copy\"
    MkDir (Destination)
    MyDirectory = App.Path & "\" ' Directory name goes here instead of the C drive root
    NameFile = Dir$(MyDirectory)
    List1.AddItem NameFile
    While NameFile <> ""
        NameFile = Dir$
        List1.AddItem NameFile
        Call FileCopy(App.Path & "\" & NameFile, Destination & NameFile)
    Wend
    Using Code Doc's code. (Untested)
    Quote Originally Posted by Vanasha
    Sorry, i'm slow.


  10. #10
    New Member
    Join Date
    Dec 2005
    Posts
    14

    Re: Copy Folder And Progress Bar (vb6)

    Quote Originally Posted by Yoshi-gr
    i found this for an instant file count
    vb Code:
    1. Dim fso As Scripting.FileSystemObject
    2. Set fso = New FileSystemObject
    3. Debug.Print fso.GetFolder("D:\source").Files.Count
    4. Set fso = Nothing
    (when i run this alone it shows me the error :invalid outside procedure for line 2)
    and then in the PBar
    vb Code:
    1. pbar.max = NumberOfFiles
    2. pbar.value = pbar.value + 1
    now how can i set theese things up in my form?
    where can i put a start button to start the copy?
    and what is happening to the subfolders?are theese files in them counted too?
    sorry for being so newbie but can someone give me some instructions?
    Yoshi,
    I have tried your code example and it works great, except it only returns the count for the single file in the folder and not that file plus those in the subfolder(s). How can I get it to give me the accurate count for all files including those in any subfolders within my source folder? I want to be able to show my users that something is actually happening (progress of copying files) and not just have the program look like it's hanging (sometimes lots of files to copy). I am copying the files using fso.copyfolder.

  11. #11
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Copy Folder And Progress Bar (vb6)

    I wrote a routine exactly like you're asking about for my own personal backup program. Instead of showing progress by filecount, I do progress by fize. That's because many are <10k programming files, while others are >1meg spreadsheets or videos or whatever. When I originally set it up to show progress based on file count, it was choppy. Much smoother going by file size.

    It's quite involved, and will not easily convert to a generic routine. It involves recursive functions, udt arrays, my entire xp library from my signature; all sorts of stuff.

    Are you absolutely sure that the standard progress dialog that pops up when you do a folder copy won't suit your needs? It's so much easier...

  12. #12
    Lively Member
    Join Date
    Aug 2009
    Posts
    98

    Re: Copy Folder And Progress Bar (vb6)

    On www.planet-source-code.com once I had uploaded the solution. You can search Copy_PBar or something like that there (exact name I don't remember now).

  13. #13
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Copy Folder And Progress Bar (vb6)

    Quote Originally Posted by Smartchap View Post
    On www.planet-source-code.com once I had uploaded the solution. You can search Copy_PBar or something like that there (exact name I don't remember now).
    It's been 4 years since last post in this thread, i don't think he's still waiting for a solution

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