简体   繁体   English

加快USB驱动器上的文件复制速度

[英]Speed up file copying on a USB drive

I have a USB drive with the following folder structure 我有一个具有以下文件夹结构的USB驱动器

<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 我需要以编程方式重新排列USB驱动器上的文件夹,如下所示

<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 eg when folder1 has 1000 sub-folders (folder1a, folder1b etc), total size of folder1 is ~4MB (~12MB on disk) - these sizes are constant. 这里的代码示例非常有用https://msdn.microsoft.com/zh-cn/library/bb762914%28v=vs.110%29.aspx但是,当涉及大量文件夹时(例如,当folder1时)它非常慢有1000个子文件夹(folder1a,folder1b等),Folder1的总大小约为4MB(磁盘上约为12MB)-这些大小是恒定的。 The copy operation for all folders combined takes upwards of 25 minutes. 合并所有文件夹的复制操作最多需要25分钟。 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: 笔记:

  • The input and final rearranged output needs to be on the USB drive - this is a sneakernet setup. 输入和最终重新排列的输出必须在USB驱动器上-这是一个运动网设置。
  • The USB drive is FAT32 or NTFS with 4GB size. USB驱动器是FAT32或4GB大小的NTFS。 We have tried USB 3.0 with no improvement in speed. 我们尝试了USB 3.0,但速度并未提高。

The copy operation for all folders combined takes upwards of 25 minutes. 合并所有文件夹的复制操作最多需要25分钟。

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). 如果将同一设备上的文件移动到另一个文件夹,则唯一需要更改的就是分配表(FAT / NTFS)。 I would recommend using File.Move or Directory.Move . 我建议使用File.MoveDirectory.Move

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM