c# - FTPWebRequest: The underlying connection was closed: An unexpected error occurred on a receive -
i've got problem when uploading files ftp server. connection works fine on local connection - however, im trying connect public ip address of system ( ftp://xx.xxx.xxx.xx ). can connect fine on filezilla upload , download files - however, reason not seem work. this code im using create webrequest: ftpwebrequest request = (ftpwebrequest)webrequest.create("ftp://xx.xxx.xx.xxx" + uploadpath); request.usebinary = true; request.keepalive = false; request.method = webrequestmethods.ftp.uploadfile; that runs fine in debug mode, filepaths allowed, etc.. however, code throwing error in section here: byte[] b = file.readallbytes(tarpath); request.contentlength = b.length; using (stream s = request.getrequeststream()) { s.write(b, 0, b.length); } ftpwebresponse ftpresp = (ftpwebresponse)request.getresponse(); if (ftpresp != null) { debug.writeline(ftpresp.statusdescription); } any ideas? i've searched through various online posts error , of them in regard...