I'm trying to figure out this element, I have made an ftp module with several actions which all work perfectly, except for the upload method. In fact it does work, but it still returns an error.
So I get a time out error after some time, but when I check on my ftp, the file is added succesfully. So I can't understand this feature..
My Code:
public static Boolean upload(string remoteFile, string localFile, string applicatie_url) {
Boolean returnbool = false;
try {
FtpWebRequest ftpRequest;
FtpWebResponse ftpResponse = null;
Stream ftpStream = null;
ftpRequest = (FtpWebRequest)FtpWebRequest.Create(host + "/" + remoteFile);
ftpRequest.Credentials = new NetworkCredential(user, pass);
ftpRequest.UseBinary = true;
ftpRequest.UsePassive = true;
ftpRequest.KeepAlive = true;
ftpRequest.Method = WebRequestMethods.Ftp.UploadFile; // upload
byte[] b = File.ReadAllBytes(localFile);
ftpRequest.ContentLength = b.Length;
ftpStream = ftpRequest.GetRequestStream();
try {
ftpStream.Write(b, 0, b.Length);
ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
} catch (Exception ex) {
// Error catching
}
// Cleanup
ftpStream.Close();
ftpRequest = null;
ftpResponse = null;
returnbool = true;
} catch (Exception ex) {
// Error catching
}
return returnbool;
}
My ex.message : 'Transfer timed out.'
My ex.stacktrace :
' ' at System.Net.FtpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00052] in /Users/builder/data/lanes/mono-mac-ui-refresh-2-10/2baeee2f/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.11/_build/mono-2.10.11.git/mcs/class/System/System.Net/FtpWebRequest.cs:411
at System.Net.FtpWebRequest.GetResponse () [0x00009] in /Users/builder/data/lanes/mono-mac-ui-refresh-2-10/2baeee2f/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.11/_build/mono-2.10.11.git/mcs/class/System/System.Net/FtpWebRequest.cs:426
at AutoPolis.FTPHelper.upload (System.String remoteFile, System.String localFile, System.String applicatie_url) [0x00078] in /Users/.../App_Code/FTPHelper.cs:92 '
Any help would be appreciated. I work on my mac with MonoDevelop as IDE, don't know if this makes any chances to this element..