Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. download logfile from an ftp server using ftpwebrequest

download logfile from an ftp server using ftpwebrequest

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netdatabasecom
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mack Ait Aoudia
    wrote on last edited by
    #1

    Hello everybody, I'm facing a weird problem in my asp.net 2.0 website using the ftpwebrequest class. I want to donwdload the logfile from an ftpserver and I get the following error: "the remote server returned an error:(530) Not Logged In" this is my code: protected void btnTestLF_Click(object sender, EventArgs e) { Uri ur = new Uri("ftp://ftp.mydomaine.com/"); Downloadlf(ur, "myname", "mypwd"); } private string Downloadlf(Uri serverUri, string name, string pwd) { // The serverUri parameter should start with the ftp:// scheme. if (serverUri.Scheme != Uri.UriSchemeFtp) { return string.Empty; } // Get the object used to communicate with the server. WebClient request = new WebClient(); request.Credentials = new NetworkCredential(name, pwd, serverUri.AbsoluteUri); try {//the next line is the problem: **byte[] newFileData = request.DownloadData(serverUri.ToString());** /*I tried also the following: byte[] newFileData = request.DownloadData(serverUri.DnsSafeHost); byte[] newFileData = request.DownloadData(serverUri.AbsoluteUri); byte[] newFileData = request.DownloadData(serverUri.AbsolutePath); **the problem still the same** */ string fileString = System.Text.Encoding.UTF8.GetString(newFileData); } catch (WebException e){ //call the ErrorManagement class to store the error in the database } return string.Empty; } Could anyone give me some help! I'll appreciate it very much!

    Just Relax And Keep It Simple.

    D 1 Reply Last reply
    0
    • M Mack Ait Aoudia

      Hello everybody, I'm facing a weird problem in my asp.net 2.0 website using the ftpwebrequest class. I want to donwdload the logfile from an ftpserver and I get the following error: "the remote server returned an error:(530) Not Logged In" this is my code: protected void btnTestLF_Click(object sender, EventArgs e) { Uri ur = new Uri("ftp://ftp.mydomaine.com/"); Downloadlf(ur, "myname", "mypwd"); } private string Downloadlf(Uri serverUri, string name, string pwd) { // The serverUri parameter should start with the ftp:// scheme. if (serverUri.Scheme != Uri.UriSchemeFtp) { return string.Empty; } // Get the object used to communicate with the server. WebClient request = new WebClient(); request.Credentials = new NetworkCredential(name, pwd, serverUri.AbsoluteUri); try {//the next line is the problem: **byte[] newFileData = request.DownloadData(serverUri.ToString());** /*I tried also the following: byte[] newFileData = request.DownloadData(serverUri.DnsSafeHost); byte[] newFileData = request.DownloadData(serverUri.AbsoluteUri); byte[] newFileData = request.DownloadData(serverUri.AbsolutePath); **the problem still the same** */ string fileString = System.Text.Encoding.UTF8.GetString(newFileData); } catch (WebException e){ //call the ErrorManagement class to store the error in the database } return string.Empty; } Could anyone give me some help! I'll appreciate it very much!

      Just Relax And Keep It Simple.

      D Offline
      D Offline
      DigiOz Multimedia
      wrote on last edited by
      #2

      Here is a good example of FTP Download: http://www.codeproject.com/cs/internet/SimpleFTPDemo.asp[^]

      Pete Soheil DigiOz Multimedia http://www.digioz.com

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups