【发布时间】:2019-05-09 10:57:42
【问题描述】:
我正在使用 PowerShell 中的 WinSCP 来管理 FTP 中的文件。在使用 WinSCP 网站上给出的标准脚本时,我收到了这个错误:
找不到类型 [WinSCP.EnumerateOptions]。
我正在使用 5.13 版 - 刚离开网站。
$remotePath = "ftp://username:password@network:port/relevantfolder/"
$localPath = "C:/Users/me/localdir"
$mask = "*.*"
$files = EnumerateRemoteFiles(
$remotePath, $mask, [WinSCP.EnumerateOptions]::AllDirectories)
foreach ($fileInfo in $files)
{
Write-Host "Downloading $($fileInfo.FullName) ..."
$filePath = [WinSCP.RemotePath]::EscapeFileMask($fileInfo.FullName)
$session.GetFiles($filePath, $localPath + "\*").Check()
}
【问题讨论】:
-
顺便说一句:还有一个适用于 PowerShell 的 WinSCP 包装器(由其他开发人员创建):powershellgallery.com/packages/WinSCP
标签: .net powershell ftp winscp winscp-net