My.Computer.Network.UploadFile error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

THE FOLLOWING CODE:

Dim strUpLoadFile As String
Dim siteUri As New Uri("ftp://wxyz.com/UpLdTest.zip")
strUpLoadFile = "C:\Trash\UpLdTest.zip"
My.Computer.Network.UploadFile(strUpLoadFile, siteUri, "johndoe", "abcdefg",
1000)

PRODUCES THIS ERROR:

Unable to cast object of type 'System.String' to type
'System.Net.ICredentials'.

THE ERROR POINTS TO THE USERNAME PARAMATER AS THE SOURCE OF THE ERROR. I'M
GUESSING THE PASSWORD PARAMETER WOULD PRODUCE AN ERROR ALSO.
WHAT IS THE CORRECT CODE TO UTILIZE My.Comp....work.UploadFile?
Thanks for your help.
 
John Brown said:
My.Computer.Network.UploadFile(strUpLoadFile, siteUri, "johndoe", "abcdefg",
1000)

The specified signature you're using doesn't exist, you're trying to use:
sourceFileName ,address ,userName ,password, connectionTimeout
but the only two close signatures are either:
sourceFileName ,address ,userName ,password
or
sourceFileName ,address ,networkCredentials ,showUI ,connectionTimeout

..NET thinks you're using the latter, and so thinks your username should be
of type ICredentials.

Remove the last parameter from your call:
My.Computer.Network.UploadFile(strUpLoadFile, siteUri, "johndoe", "abcdefg")
 
Back
Top