Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

FTP Upload in SAP B1 -Time out Error

Hello Friends,

My task is to upload a CSV file into a specified FTP loacation.But the system is throwing time out message from a line of the code. Please help me out on this issue.

  public static string UploadFile(string ftpUrl, string userName, string password, string uploadFTPDirectory, string localFilePath)


            string PureFileName = new FileInfo(localFilePath).Name;

            String uploadUrl = String.Format("{0}{1}/{2}", ftpUrl, uploadFTPDirectory, PureFileName);

            //String uploadUrl = String.Format("{0}{1}", ftpUrl, uploadFTPDirectory);

            FtpWebRequest ftpRequest = (FtpWebRequest)FtpWebRequest.Create(uploadUrl);

            ftpRequest.Proxy =null;

            ftpRequest.Method = WebRequestMethods.Ftp.UploadFile;

            ftpRequest.Credentials = new NetworkCredential(userName, password);

            ftpRequest.UseBinary = true;

            ftpRequest.UsePassive = false;



                byte[] fileData = File.ReadAllBytes(localFilePath);

                ftpRequest.ContentLength = fileData.Length;

                using (Stream fileStream = ftpRequest.GetRequestStream())


                    fileStream.Write(fileData, 0, fileData.Length);



                using (FtpWebResponse ftpResponse = (FtpWebResponse)ftpRequest.GetResponse())----------'Sytem throws the Timed out Message here.'


                    return ftpResponse.StatusDescription;



            catch(WebException e)


               string s = ((FtpWebResponse)e.Response).StatusDescription;

               return s;



With thanks and Regards,

Rajeev M Kartha


I dont know why you posted this here. but you might want to disable firewall.

FTP does require two ports to work 20, and 21.


0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question