Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to list all file in a folder to listbox with a progress bar to perform this.
Help, please!

What I have tried:

Can i use background worker for this problem
Posted
Updated 15-Jul-19 21:06pm
Comments
Dominic Burford 16-Jul-19 3:07am    
What have you tried? Do you have any code to show? Are you getting an error? Break the problem down into manageable chunks. 1. Get the list of files from the folder 2. Populate the listbox from this list 3. Add a progress bar

1 solution

That depends on how you are doing it.
If you use Directory.GetFiles[^] then no - it's a monolithic operation which only returns when it's done, so a progress bar would have to be a guess (since you have no idea how many files it will fetch until it;s done it, you have no idea what 10%, 20%, etc complete actually are!

It is possible: c# - Show progress when searching all files in a directory - Stack Overflow[^] but to be honest, it's a fair amount of work for very little reward. A "marquee" style progress bar and GetFiles normally works fine for me.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900