Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 496745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:42:54+00:00 2026-05-13T05:42:54+00:00

If I use System.Net.FtpWebRequest to upload a file to a vsftpd server, do I

  • 0

If I use System.Net.FtpWebRequest to upload a file to a vsftpd server, do I need to use GetResponse to check if the file was uploaded correctly? Or do I get an exception for every error? What in System.Net.FtpWebResponse should I check on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:42:55+00:00Added an answer on May 13, 2026 at 5:42 am

    Yeah, you want to grab the FTPWebResponse object from the request object…like this:

     FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
     request.Method = WebRequestMethods.Ftp.UploadFile;
    
     FtpWebResponse response = (FtpWebResponse) request.GetResponse();
     request.KeepAlive = false;
    
     byte[] fileraw = File.ReadAllBytes("CompleteLocalPath");
    
     try
     {
         Stream reqStream = request.GetRequestStream();
    
         reqStream.Write(fileraw, 0, fileraw.Length);
         reqStream.Close();
     }  
     catch (Exception e)
     {
         response = (FtpWebResponse) request.GetResponse();
         // Do something with response.StatusCode
         response.Close();
     }
    

    You will want to check http://Ftp.WebResponse.StatusCode.

    There are a quite a few members in StatusCode that can be returned, so checking against it can be tricky.

    Here’s a list of codes/descriptions that might be returned:

    FtpStatusCode

    EDIT: If something goes wrong with a transfer it should throw an exception when you fire up a stream writer. What you can do is wrap a try-catch around it all, and if something goes wrong you will be able to get the status code and print it out to whatever log medium you are using so you can see what the specific problem is. I’ve amended the code above to reflect all of this (Using just one way of transferring, you can use your own).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I receive the following error when I use weblcient to upload a file System.Net.WebException:
I use a System.Timers.Timer in my Asp.Net application and I need to use the
In order for my application (.Net 1.1) to use the system configured proxy server
Let's say I create and execute a System.Net.FtpWebRequest . I can use catch (WebException
We've got a few pages in our web systems that use the .net system.net.mail
I use System.Web.Services.WebMethodAttribute to make a public static method of an ASP.NET page callable
I'm trying to use the code below to send messages via System.Net.Mail and am
In .net frameworks 1.1, I use System.Configuration.ConfigurationSettings.AppSettings[name]; for application settings. But in .Net 2.0,
So in my simple learning website, I use the built in ASP.NET authentication system.
In .NET 3.5, I'm going to be working with System.Reflection to use AOP (probably

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.