Currently I'm doing project in vb.net and I want to set the progress bar while copying files from one folder to another. And the progress bar should move towards completion according to amount of file copied.
相关问题
- 'System.Threading.ThreadAbortException' in
- how to use special characters like '<'
- C# to VB - How do I convert this anonymous method
- Scaling image for printing
- visual basics equal to or greater than
相关文章
- vb.net 关于xps文件操作问题
- Checking for DBNull throws a StrongTypingException
- Using the typical get set properties in C#… with p
- Load a .NET assembly from the application's re
- C# equivalent of VB DLL function declaration (Inte
- What other neat tricks does the SpecialNameAttribu
- Automatically install updates with ClickOnce deplo
- Resetting Experimental instance of Visual Studio
Not so new question, but here's an answer nonetheless. The following code will achieve the desired result whereby an individual file's progress is tracked. It uses a 1 MiB buffer. Depending on your system's resources, you can adjust the buffer accordingly to tweak the performance of the transfer.
Concept: Count each byte as it is read/written and report the progress based on the total size of the source file, using file streams.
Concept used: Get the
count of files
in thesource directory
, and then whenevercopying
afile
fromsource folder
todestination folder
increment avariable
to trace how manyfiles
get transferred. Now calculate thefiles
transferred percentage by using the following formula,And then after getting the
% of files transferred
, update the progress bar's value by using it.Try this code :
Tested with IDE