Reputation: 11
I am trying to copy the file from ftp to local and I am using the code below to do my file copy function and in doing so i am getting an error that files already exist is there any way that i can bypass this and if the file exist it just say do nothing otherwise do the file copy or overwrite the file copied.
Docopy = True
If Docopy Then
' I want some function here so he can tell that file exist
' Write now i am using Kill(CopyTo) but it only works once
My.Computer.Network.DownloadFile(CopyFrom, CopyTo, UserName, Password)
End If
Upvotes: 0
Views: 720
Reputation: 2089
You need to check if the file exists before you do the copy.
Docopy = True
If Docopy Then
' I want some function here so he can tell that file exist
If FileExists("ThisFilenameToTest.txt") = True Then Kill(CopyTo)
'copy the file
My.Computer.Network.DownloadFile(CopyFrom, CopyTo, UserName, Password)
End If
Upvotes: 0
Reputation: 7465
There's some extra parameters you can use for that:
My.Computer.Network.DownloadFile(CopyFrom, CopyTo, UserName, Password, False, 100, True)
Reference: https://msdn.microsoft.com/en-us/library/ms127879(v=vs.110).aspx
Upvotes: 1