Помогите разобраться с FTP.
Суть программы в том что она должна залить файл с диска С на FTP.
Но возникла слудующая проблема.
При попытке подключения она выдаёт ( Запрашиваемый URI-адрес недопустим для этой команды FTP.)
Программа создана в ConsoleApplication.
Помогите разобратся.
- Код: Выделить всё
Imports System.Net
Imports System.IO
Imports System.Text
Module Module1
Sub Main()
' Get the object used to communicate with the server.
Dim request As FtpWebRequest = DirectCast(WebRequest.Create("ftp://ftp.narod.ru/"), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.UploadFile
request.Credentials = New NetworkCredential("Login", "Password")
' Copy the contents of the file to the request stream.
Dim sourceStream As New StreamReader("C:\testfile.txt")
Dim fileContents As Byte() = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd())
sourceStream.Close()
request.ContentLength = fileContents.Length
Dim requestStream As Stream = request.GetRequestStream()
requestStream.Write(fileContents, 0, fileContents.Length)
requestStream.Close()
Dim response As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse)
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription)
response.Close()
End Sub
End Module