#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    7
    Rep Power
    0

    FTP Upload with FTP Account


    Hey Guys,

    Currently have a code that uploads an .xml file to my server. However, this code only works if I use my cPanel credentials. I think it would be easier, and much safer, if possible, to be able to connect via an ftp account. Any suggestions?

    Code:
                  
    Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://ftp.myserver.com), System.Net.FtpWebRequest)                     request.Credentials = New System.Net.NetworkCredential("cpaneluser", "cpanelpass")                     request.Method = System.Net.WebRequestMethods.Ftp.UploadFile                      Dim file() As Byte = System.IO.File.ReadAllBytes(path)                     Dim strr As System.IO.Stream = request.GetRequestStream()                     strr.Write(file, 0, file.Length)                     strr.Close()                     strr.Dispose()
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,453
    Rep Power
    4539
    Back in the VB6 days there was an Inet control that gave you ftp support from your code. There must be something similar in NET, try searching for ftp vb controls

    The command-line ftp program can be called from code. For security though, I'd want to use ftps or some other secure transfer, basic ftp is not secure.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    23
    Rep Power
    0

    the black arts


    Originally Posted by Feartheyankees
    Hey Guys,

    Currently have a code that uploads an .xml file to my server. However, this code only works if I use my cPanel credentials. I think it would be easier, and much safer, if possible, to be able to connect via an ftp account. Any suggestions?

    Code:
                  
    Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://ftp.myserver.com), System.Net.FtpWebRequest)                     request.Credentials = New System.Net.NetworkCredential("cpaneluser", "cpanelpass")                     request.Method = System.Net.WebRequestMethods.Ftp.UploadFile                      Dim file() As Byte = System.IO.File.ReadAllBytes(path)                     Dim strr As System.IO.Stream = request.GetRequestStream()                     strr.Write(file, 0, file.Length)                     strr.Close()                     strr.Dispose()
    the easiest way is to make a batch file and use some of the black arts available since the beginning of time..

    your windows system has been able to ftp sinc it was dos

    you can use all the old dos commands to traverse a site and send or indeed retrieve files in both ascii and binary format. you can even read the settings from a plain text file..

    if You want to try this please ask

    Bill Stewart - here to talk

IMN logo majestic logo threadwatch logo seochat tools logo