我有一个操作可以非常快速地在本地驱动器上复制文件,但是当它针对服务器运行时,它会大大减慢速度。我有一个想法,也许我可以把它扔到 Parallel.For 上。可能吗?下面是我的代码。
Dim FilesToCopy As HashSet(Of String) = New HashSet(Of String)
'FilesToCopy holds the files names that will be copied because
'the "copy" folder can have hundreds of files, but only a small subset will be copied
For Each Item In FilesToCopy
FileName = My.Computer.FileSystem.GetName(Item)
Splitter = Regex.Split(FileName, "_", RegexOptions.IgnoreCase)
ThisHour = Integer.Parse(Splitter(9).Substring(0, 2)) + 1
My.Computer.FileSystem.CopyFile(String.Concat(GrabPath, "\", Item), String.Concat(DropPath, "\", _
StaticFileName, ThisHour.ToString, ".NETLOSS"), FileIO.UIOption.OnlyErrorDialogs, UICancelOption.ThrowException)
SBuilder.AppendLine(String.Concat(StaticFileName, ThisHour.ToString, ".NETLOSS"))
LogFile.WriteLine(String.Concat("INFO The following file (", Item, ") was copied from the ", GrabPath, _
" folder to the ", DropPath, " folder."))
Next