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. General Programming
  3. C#
  4. File Upolad

File Upolad

Scheduled Pinned Locked Moved C#
sysadminhelptutorial
4 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.
  • B Offline
    B Offline
    B87
    wrote on last edited by
    #1

    Hi, I need to upload file in a folder at FTP server,i have already posted this but i need a coding guide not a software for this. The code i used is, txtfilurl.Text = FileUpload1.PostedFile.FileName; FileInfo filename = new FileInfo(txtfilurl.Text); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(txtaddr.Text + "/" + filename.Name); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(txtuser.Text, txtpass.Text); request.KeepAlive = false; request.UseBinary = true; Stream ftpstream = request.GetRequestStream();//--->This line shows the error FileStream file = File.OpenRead(txtfilurl.Text); int len = 1024; byte[] buff = new byte[len]; int bytesread = 0; do { bytesread = file.Read(buff, 0, len); ftpstream.Write(buff, 0, bytesread); } while (bytesread != 0); file.Close(); ftpstream.Close(); Error msg is:Web exception The remote server returned an error: (550) File unavailable (e.g., file not found, no access).

    D 1 Reply Last reply
    0
    • B B87

      Hi, I need to upload file in a folder at FTP server,i have already posted this but i need a coding guide not a software for this. The code i used is, txtfilurl.Text = FileUpload1.PostedFile.FileName; FileInfo filename = new FileInfo(txtfilurl.Text); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(txtaddr.Text + "/" + filename.Name); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(txtuser.Text, txtpass.Text); request.KeepAlive = false; request.UseBinary = true; Stream ftpstream = request.GetRequestStream();//--->This line shows the error FileStream file = File.OpenRead(txtfilurl.Text); int len = 1024; byte[] buff = new byte[len]; int bytesread = 0; do { bytesread = file.Read(buff, 0, len); ftpstream.Write(buff, 0, bytesread); } while (bytesread != 0); file.Close(); ftpstream.Close(); Error msg is:Web exception The remote server returned an error: (550) File unavailable (e.g., file not found, no access).

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Judging by the error, you gave an invalid path to the file on the FTP server. It's impossible to tell just by looking at the code.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      B 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Judging by the error, you gave an invalid path to the file on the FTP server. It's impossible to tell just by looking at the code.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        B Offline
        B Offline
        B87
        wrote on last edited by
        #3

        Hi, Thanx for replying,i am sure that i have given the right path i have checked many times. Is there is any other way to do the upload.

        D 1 Reply Last reply
        0
        • B B87

          Hi, Thanx for replying,i am sure that i have given the right path i have checked many times. Is there is any other way to do the upload.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          In that case, I'd use something like EtheReal to watch the TCP traffic coming out of your machine and see what the FtpWebRequest is actually sending to the FTP server.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          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