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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:27:29+00:00 2026-05-25T16:27:29+00:00

I am using FtpWebRequest to upload a file. Facing a problem of which i

  • 0

I am using FtpWebRequest to upload a file.
Facing a problem of which i am not getting solution.

While uploading a heavy file if network get disconnected then FTP server acquires lock on file being uploaded, now when user tries to re upload the same file then it get access denied error.

I have set TimeOut and ReadWriteTimeOut to 5 secs of FtpWebRequest on FTP Server it is 10 secs.
Even if i try to upload same file after an Hour then also same problem exist.

 // Get the object used to communicate with the server.
  request = (FtpWebRequest)WebRequest.Create(new Uri("ftp://" + FtpInfo.FtpServer.Trim() + "/" + FtpInfo.FtpFolderPath.Trim() + "/" + FileName.Trim()));
   request.Method = WebRequestMethods.Ftp.UploadFile;
   request.Proxy = null;

   // FTP site uses anonymous logon.
    request.Credentials = new NetworkCredential(FtpInfo.UserNameForFTP.Trim(), FtpInfo.PasswordForFTP.Trim());
    request.UsePassive = FtpInfo.UsePassive;
    request.KeepAlive = FtpInfo.KeepAlive;
    request.Timeout = FtpInfo.TimeOut; //Milliseconds
    request.UseBinary = true;
    request.ReadWriteTimeout = FtpInfo.TimeOut; //Milliseconds

                        FileInfo fi = new FileInfo(SourceLocation);
                        long length = fi.Length;
                        BytesUploaded = length;

                        long uploadSize = 0;
                        if (chunks == 0)
                        {
                            chunks = 1024;
                        }
                        else
                        {
                            buffLength = chunks;
                        }
                        byte[] buff = new byte[buffLength];
                        int contentLen;
                        using (FileStream fs = fi.OpenRead())
                        {
                            using (Stream strm = request.GetRequestStream())
                            {
                                contentLen = fs.Read(buff, 0, buffLength);
                                try
                                {
                                    while (contentLen != 0)
                                    {
                                        Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate() { lblProgress.Content = "Uploading '" + FileName + "'......" + "Bytes Uploaded (" + uploadSize.ToString() + "/" + length.ToString() + ")"; });
                                        strm.Write(buff, 0, contentLen);
                                        uploadSize += contentLen;
                                        contentLen = fs.Read(buff, 0, buffLength);
                                    }
                                    strm.Close();
                                }
                                catch (Exception ex)
                                {
                                    if (strm!=null)
                                    {
                                        try
                                        {
                                            strm.Close();
                                        }
                                        catch
                                        {
                                            throw ex;
                                        }
                                    }
                                    throw ex;
                                }
                            }
                            fs.Close();
                        }


                        try
                        {
                            //requestStream.Close(); -orignal
                            fi = null;
                            request=null;
                        }
                        catch { }
  • 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-25T16:27:30+00:00Added an answer on May 25, 2026 at 4:27 pm

    This was problem related to the FTP Server we were using, when we switched FTP server to IIS then everything worked smoothly.
    Thanks for all the help

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

Sidebar

Related Questions

We are using FTPWebRequest class in my project to upload PDF files. For uploading
I'm using ftpwebrequest to upload and download a file. So far my code does
I am trying to upload a file via ftp using FtpWebRequest as below: ftpRequest
I am using FtpWebRequest to append data to a mainframe file. Each record appended
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I want to do Multiple Download/Upload parallely in FTP using C# without using FTPWebRequest.
I'm trying to use an FtpWebRequest to get the size of a file on
I am uploading files to ftp using FtpWebRequest . I need to show the
I'm using ftpwebrequest to upload some files to an old mainframe system (MPE/IX) that
I try to list file details using FtpWebRequest but very frequently it fails with

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.