我在使用FileSystemObject.CopyFile
时遇到问题。我想我正确地使用它,从我读过的论坛,但我仍然得到以下编译器错误:FileSystemObject CopyFile:Unhanded Exception
ArgumentException was unhandled: Value does not fall within expected range
下面是代码:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim fso As New Scripting.FileSystemObject
Dim testfolderchk
testfolderchk = Dir("C:\Test\")
Dim inforeader As System.IO.FileInfo
Dim filedestinationcheck = Dir("C:\Test2\")
If testfolderchk <> "" Then
If Microsoft.VisualBasic.Left(testfolderchk, 4) = "test" Then
inforeader = My.Computer.FileSystem.GetFileInfo("C:\Test" & testfolderchk)
filetime = (inforeader.LastWriteTime)
If testfolderchk = filedestinationcheck Then GoTo skipfile
If testfolderchk = filedestinationcheck2 Then GoTo skipfile
Else : GoTo skipfile
End If
End If
fso.CopyFile(testfolderchk, filedestinationcheck, True)
的'系统.IO'命名空间具有各种与FileSystemObject相比更适合.NET代码的文件相关方法。 – Plutonix
建议?任何人? – user2644085
'建议?'是的,不要使用FSO并且不要使用'GoTo'。只需进行一点研究,您可以在这里找到数百个文件副本小程序 – Plutonix