开发者

Send file FTP over SSL with custom port number

I want to upload and download a file to FTP over ssl with custom port number or FTP with implicit SSL. I am using .net ftpwebrequest & ftpwebresponse method for this. here is my code:

Dim reqObj As FtpWebRequest = CType(WebRequest.Create(_Url + filename), FtpWebRequest) 
reqObj.Method = WebRequestMethods.Ftp.UploadFile 
reqObj.KeepAlive = False 
If _IsSSLEnable Then 
reqObj.UseBinary = True 
End If 
reqObj.Credentials = New NetworkCredential(_UserName, _Password) 
If _IsSSLEnable Then 
reqObj.EnableSsl = _IsSSLEnable Net.ServicePointManager.ServerCertificateValidationCallback = AddressOf validateCert  
End If 
Dim streamResponse As Stream 
streamResponse = reqObj.GetRequestStream() 

I am getting error after this...

The server returned an address in response to the PASV command that is different than the address to which the FTP connection was made.

But if i Add

reqObj.UsePassive = False

It gives me error:

The operation has开发者_Go百科 timed out

this is working fine for normal ftp and ftp over ssl but not for custom port number or implicit ssl.

Can you please tell me does .net support this?

Or I have to use other method for this case

Thanks,

Hemant


there is a very similar question already on SO: Set Port number when using FtpWebRequest in C#

it looks like the solution was this:

yourFtpWebRequest.UsePassive = false;

but check that question and answer for more details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜