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. Below is the code i use. 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; try { byte[] fileData = File.ReadAllBytes(localFilePath); ftpRequest.ContentLength = fileData.Length; using (Stream fileStream = ftpRequest.GetRequestStream()) { fileStream.Write(fileData, 0, fileData.Length); fileStream.Close(); } 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; } }
-
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. Below is the code i use. 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; try { byte[] fileData = File.ReadAllBytes(localFilePath); ftpRequest.ContentLength = fileData.Length; using (Stream fileStream = ftpRequest.GetRequestStream()) { fileStream.Write(fileData, 0, fileData.Length); fileStream.Close(); } 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; } }