VB.NET报错BC30057:调用Copy方法时实参过多,求技术解决方案
错误BC30057的排查与解决
错误原因
你代码里的file是String类型变量,对应String类的Copy方法仅接受1个参数,但你传入了2个参数,导致触发BC30057错误。而你实际需要调用的是System.IO.File类的静态Copy方法(支持源路径、目标路径两个参数)。
修复方法
将第36行的file.Copy(file, destinationFile)替换为:
File.Copy(file, destinationFile)
如果需要覆盖已存在的目标文件,可以添加第三个布尔参数:
File.Copy(file, destinationFile, True)
完整修正后的CopyFolder方法片段
' Copy each file in the source folder to the destination folder For Each file As String In Directory.GetFiles(sourceFolder) ' Get the destination file path Dim fileName As String = Path.GetFileName(file) Dim destinationFile As String = Path.Combine(destinationFolder, fileName) ' Copy the file(已修正) File.Copy(file, destinationFile) ' Update the progress bar UpdateProgressBar() Next
内容的提问来源于stack exchange,提问作者Paul Martins
相关产品推荐
相关产品推荐

