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 225471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:25:00+00:00 2026-05-11T19:25:00+00:00

I keep getting a exception when I try to FTP to my Win 2008

  • 0

I keep getting a exception when I try to FTP to my Win 2008 Server from C# code using VS2008 as debugger.

My test class looks like this:

public class FTP
{
    private string ftpServerIP = "192.168.10.35:21";
    private string ftpUserID = "Administrator";
    private string ftpPassword = "XXXXXXXX";
    private string uploadToFolder = "uploadtest";

    public void Upload(string filename)
    {
        FileInfo fileInf = new FileInfo(filename);
        string uri = "ftp://" + ftpServerIP + "/" + uploadToFolder + "/" + fileInf.Name;
        FtpWebRequest reqFTP;

        reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
        reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
        reqFTP.KeepAlive = false;
        reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
        reqFTP.UseBinary = true;
        reqFTP.ContentLength = fileInf.Length;

        int buffLength = 2048;
        byte[] buff = new byte[buffLength];
        int contentLen;

        FileStream fs = fileInf.OpenRead();
        try
        {
            Stream strm = reqFTP.GetRequestStream();
            contentLen = fs.Read(buff, 0, buffLength);

            while (contentLen != 0)
            {
                strm.Write(buff, 0, contentLen);
                contentLen = fs.Read(buff, 0, buffLength);
            }

            strm.Close();
            fs.Close();
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }
}

When I execute the code I get a Connection Failed with FTP error 227 in the GetRequestStream() call.
In the exception I can see the connection fails to: 192.168.10.35:52184

I have no idea how it comes up with port 52184.
I specify in the ftpServerIP that it should be port 21.

I have found a few persons with the same issues on google but I haven’t found a good example on how this is solved and I still don’t understand why it happens.

Anyone know how to handle this issue??

UPDATE:

I have tried to connect to a different FTP account and there it all works fine. Therefore I tested my 192.168.10.35:21 FTP but it works fine in CuteFTP Pro and the likes.
This just makes it even more strange..

  • 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-11T19:25:01+00:00Added an answer on May 11, 2026 at 7:25 pm

    My guess would be Windows firewall issues, FTP uses other ports than just port 21 – sometimes changing the FTP mode from active to passive helps to get things working.

    reqFTP.UsePassive = false;
    

    Look at this good article on FTP: Active FTP vs. Passive FTP, a Definitive Explanation

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

Sidebar

Related Questions

I keep getting this exception (in the title) whenever I try to get the
I keep getting a invalid identifier exception when I try to run the below
I'm trying to build a file server using Java TCP sockets. I keep getting
I keep getting stuck conceptually on deciding an Exception-handling structure for my project. Suppose
I keep getting compiler errors when I try to access flashVars in an AS3
I keep getting a PermGen error on my Tomcat 6 server. I know what
I keep getting an SWTException that says Invalid Thread Access when I try and
I keep getting an SerializationException whenever I try to deserialize a list of doubles
I'm trying to send SMTP e-mails using PHPMailer, but I keep getting this error
I try reading data from SQL Server 2005 and filling it in a TableAdapter

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.