-
Sep 30th, 2007, 08:26 AM
#1
Thread Starter
New Member
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
-
Sep 30th, 2007, 09:09 AM
#2
Addicted Member
Re: Copy Folder And Progress Bar (vb6)
Take a look at the file system object. It can copy files etc.
Originally Posted by Vanasha
Sorry, i'm slow.
-
Oct 1st, 2007, 12:56 AM
#3
Thread Starter
New Member
Re: Copy Folder And Progress Bar (vb6)
@vanasha what about a progress bar?
-
Oct 1st, 2007, 04:15 AM
#4
Frenzied Member
Re: Copy Folder And Progress Bar (vb6)
Use the progress bar control. Press Ctl+t -> Microsoft Windows Common control 6.0 (sp6)
-
Oct 1st, 2007, 04:21 AM
#5
Lively Member
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...
-
Oct 1st, 2007, 05:54 AM
#6
Re: Copy Folder And Progress Bar (vb6)
See Post #2 in this thread. Is this what you are looking for?
-
Oct 1st, 2007, 06:20 AM
#7
Thread Starter
New Member
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.
-
Oct 1st, 2007, 06:42 AM
#8
Thread Starter
New Member
Re: Copy Folder And Progress Bar (vb6)
i found this for an instant file count
vb Code:
Dim fso As Scripting.FileSystemObject
Set fso = New FileSystemObject
Debug.Print fso.GetFolder("D:\source").Files.Count
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:
pbar.max = NumberOfFiles
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.
-
Oct 1st, 2007, 09:50 AM
#9
Addicted Member
Re: Copy Folder And Progress Bar (vb6)
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)
Originally Posted by Vanasha
Sorry, i'm slow.
-
May 29th, 2008, 10:06 AM
#10
New Member
Re: Copy Folder And Progress Bar (vb6)
Originally Posted by Yoshi-gr
i found this for an instant file count
vb Code:
Dim fso As Scripting.FileSystemObject
Set fso = New FileSystemObject
Debug.Print fso.GetFolder("D:\source").Files.Count
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:
pbar.max = NumberOfFiles
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.
-
May 29th, 2008, 10:38 AM
#11
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...
-
Apr 24th, 2012, 12:00 AM
#12
Lively Member
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).
-
Apr 24th, 2012, 12:36 AM
#13
Re: Copy Folder And Progress Bar (vb6)
Originally Posted by Smartchap
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|