Home All Groups Group Topic Archive Search About
Author
27 Sep 2006 11:36 PM
jonathandrott
Hi, all.  new to this ftp stuff.  i found this information on the msdn,
but i don't understand some things.  why won't this code resolve to a
IP based ftp server?  how can i download everything at this site
without a GUI?  Thanks ahead of time.

Imports System.IO
Imports System.Net
Imports System.Text

Public Class SimpleFTPClient
    Public Function download() As FtpStatusCode
        Try

            sqlUser = "xxx"
            sqlPass = "xxx"
            sqlIP = "xxx.xxx.xxx.xxx"

            Dim ftpRequest As FtpWebRequest =
CType(WebRequest.Create(sqlIP), FtpWebRequest)

            ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile

            Dim ftpResponse As FtpWebResponse =
CType(ftpRequest.GetResponse, FtpWebResponse)
            Dim stream As Stream = Nothing
            Dim reader As StreamReader = Nothing
            Dim writer As StreamWriter = Nothing
            Dim destinationFile As String
            destinationFile = "C:\FrankSilvaFTP"
            Try
                stream = ftpResponse.GetResponseStream
                reader = New StreamReader(stream, Encoding.UTF8)
                writer = New StreamWriter(destinationFile, False)
                writer.Write(reader.ReadToEnd)
                Return ftpResponse.StatusCode
            Finally
                stream.Close()
                reader.Close()
                writer.Close()

            End Try
        Catch ex As Exception
            Throw ex
        End Try

    End Function
    Public sqlUser As String
    Public sqlPass As String
    Public sqlIP As String
End Class

Author
28 Sep 2006 1:52 AM
Homer J Simpson
<jonathandr***@gmail.com> wrote in message
news:1159400212.149986.309940@h48g2000cwc.googlegroups.com...

> Hi, all.  new to this ftp stuff.  i found this information on the msdn,
> but i don't understand some things.  why won't this code resolve to a
> IP based ftp server?  how can i download everything at this site
> without a GUI?

Why do you want to?