Reputation: 300
I have a USB drive with the following folder structure
<root of USB>
-- folder1
-- folder1a
-- file1ai
-- file1aii
-- file1aiii
-- folder1b
-- ...
-- ...
-- folder2
-- folder2a
-- folder2b
-- ...
-- folder3
-- folder3a
-- folder3b
-- ...
Programmatically I need to rearrange the folders on the USB drive as follows
<root of USB>
-- new folder
-- folder1a
-- folder1b
-- ...
-- folder2
-- folder2a
-- folder2b
-- ...
-- folder3
-- folder3a
-- folder3b
-- ...
The code sample here works great https://msdn.microsoft.com/en-us/library/bb762914%28v=vs.110%29.aspx BUT it is super slow when there are a huge number of folders involved e.g. when folder1 has 1000 sub-folders (folder1a, folder1b etc), total size of folder1 is ~4MB (~12MB on disk) - these sizes are constant. The copy operation for all folders combined takes upwards of 25 minutes. Is there any way to speed up this operation? I'm hoping there is some super clever way of renaming the folders/manipulating the allocation table/whatever to make this happen.
Notes:
Upvotes: 0
Views: 385
Reputation: 54628
The copy operation for all folders combined takes upwards of 25 minutes.
Why are you copying files? If you move a file on the same device to another folder, the only thing that needs to change is the Allocation Table (FAT/NTFS). I would recommend using File.Move or Directory.Move.
Upvotes: 6