谁能给我正确的语法如何在 vb.net 中编写以下代码
public static void CopyFiles(string fromFolder, string toFolder)
{
Parallel.ForEach<string>(Directory.EnumerateFiles(fromFolder, "*"), f =>
{
File.Copy(f, toFolder + @"\" + Path.GetFileName(f), true);
});
}
我尝试使用 developerfusion.com/tools/convert/csharp-to-vb 进行转换,转换后的代码是:-
Public Shared Sub CopyFiles(fromFolder As String, toFolder As String)
Parallel.ForEach(Of String)(Directory.EnumerateFiles(fromFolder, "*"), Function(f)
File.Copy(f, toFolder & "\" & Path.GetFileName(f), True)
End Function)
End Sub
及其抛出编译时异常。请让我知道,这段代码出了什么问题。