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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:48:26+00:00 2026-05-13T16:48:26+00:00

I am writing a code to upload a zip file to an ftp server.

  • 0

I am writing a code to upload a zip file to an ftp server. Surprisingly the code works fine for small files, but with bigger files I end up in problem. I am using Stream object and I have noted that my code is getting stuck while trying to close the Stream (only for big files). The code runs fine if I do not close the Stream (even for big files). Does anyone see any logic in why this is happening. And if I don’t close the stream is it possible that I might end up in problem in future.

Code extract:

FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(@"ftp://" + ftpServerIP + @"/" + fileInf.Name));
Stream strm = reqFTP.GetRequestStream();

The code stops responding (when the upload file is big) at:

strm.Close();

There is no exception as this part is within try-catch.

I don’t know how to get a stack trace.

  • 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-13T16:48:26+00:00Added an answer on May 13, 2026 at 4:48 pm

    I don’t know specifically what error you’re getting when closing the stream, but in our application, we do a lot of large file uploads (videos and images). Here’s how we write to our FTP stream:

    request.KeepAlive = false; // This eliminated some of our stream closing problems
    
    using (Stream stream = request.GetRequestStream())
    {
        stream.Write(file.Data, 0, file.Data.Length);
    }
    

    I thought that doing a using block would effectively do the Close call on its own, but maybe it also performs other necessary cleanup. Also notice I turned off the FTP keepalives, which caused us problems in some of the third-party FTP sites we uploaded to.

    You really should look at the specific exception you’re receiving rather than swallowing all exceptions. The error message will most-likely tell you what’s wrong. The most common problems we encountered had to do with active vs. passive mode and the keepalives.

    Edit:

    To discover what was really going on when we had FTP issues with CDNs (and it happens way too frequently), we sometimes had to turn tracing on in our application. See this link for details on how to enable tracing. Another option is to use a tool like Wireshark to sniff the conversation between your application and the FTP server. If you can see what’s going in in the FTP protocol, you’ll have a much better chance of resolving the issue.

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

Sidebar

Related Questions

I am using this code to upload files, but when I upload a file
I am writing an upload file code but when I run, it says: undefined
I'm writing a bit of code to upload a file from the device to
I'm writing code to import dozens of moderate sized text files into SQL SERVER
I guys, i'm writting code to upload file, zip them and delete tmp file.
I'm new to python and I'm writing a code to upload a file using
I am writing a utility that will zip a file (or set of files)
I am writing a code that will let me upload files. The code is
I am writing a small file upload utility thing as part of a larger
I'm writing a WCF Service to Upload file using REST. But my probleme come

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.