我在使用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