2

我搜索了这个站点并通过 Powershell 找到了一个 FTPWebRequest 示例。我使用它,它工作正常。但是,当我通过 EnableSsl=$True 启用 SSL 时,我得到的只是超时或延迟的“227 进入被动模式”,这会中断进程。只要我禁用 EnableSsl,我就可以直接飞过去。有人可以指出我正确的方向吗?FTP 主机支持 SSL。

在获得列表并找到匹配项后,我最终希望将方法更改为 DownloadFile 并循环下载文件的代码。不过,我想安全地做到这一点。


# Create an FTPWebRequest object to handle the connection to the FTP server
$ftprequest = [System.Net.FtpWebRequest]::Create($sourceuri)

# Set the request's network credentials for an authenticated connection
$ftprequest.Credentials = New-Object System.Net.NetworkCredential($username,$password)

# Set FTPWebRequest method to ListDirectory
$ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::ListDirectory
$ftprequest.EnableSsl = $True
$ftprequest.UseBinary = $False
$ftprequest.UsePassive = $True
$ftprequest.KeepAlive = $False

$ftpresponse = $ftprequest.GetResponse()

Write-Out $ftpresponse.StatusCode
Write-Out $ftpresponse.StatusDescription
4

1 回答 1

-1

来发现,自发的问题是服务器端的。

于 2009-10-19T20:55:12.443 回答