c# - Use multithreading for multiple file copies -


I have to copy a large number of files (10000 files)

Because more time in copying looks like .

  I have used this code:  
  I have tried to use two thread instead of one thread, one of the strange number of files in the list  

ThreadPool.QueueUserWorkItem (New WaitCallback (this.RanFileCopy), object)

but to make a copy and copy the second list, any significant There is no difference when using single thread and using two threads.

What could be the reason for this?

File copy is not a CPU process, it is an IO process, so multilevel or parallelism will not help you Can do it

Multithreading will slow you down in almost all cases. If the disc is SSD then it has a limited speed for R / W and it will use it efficiently with single thread. If you use parallelism, then you will split your speed into pieces and it will be one for HDD The huge upper part will make

Multithreading helps you with more than one disc case only when you read from different disks and write different disks.

If the files are too small for zipping and unzipping the target drive may be faster in most cases, and if you zip the file with less compression it will be much faster.

  using System.IO; Using System.IO.Compression; ..... string startPath = @ "c: \ example \ start"; String zippath = @ "c: \ example \ result.zip"; String extractPath = @ "c: \ example \ extract"; ZIPFile.CreditForreDirectory (StartText, ZIPPath, Compression Level, Fastest, True); ZipFile.ExtractToDirectory (ZIPPath, Exit path);  

More implementation details here


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -