重命名SFTP服务器上的文件,WinSCP赋予.NET程序集以下错误来当试图将文件从一个文件夹(文件夹上传)移动到另一个(存档),这是可以使用WinSCP赋予.NET程序集在PowerShell中SFTP服务器上:在PowerShell中
You cannot call a method on a null-valued expression.
At C:\Attendance Integration\Scripts\Power Shell
Script\Download&MoveToArchive.ps1:28 char:5
+ $Sftp.RenameRemoteFile($existingFilepath,$newFilepath)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
下面是我使用的传输文件代码:
# Connect
$session.Open($sessionOptions)
$existingFilepath = "/upload/attendance v2-201709220930.csv"
$newFilepath = "/Archive/attendance v2-201709220930.csv"
# Transfer files
$session.GetFiles($existingFilepath,"C:\Transfer Files\Attendance Files\*").Check()
$Sftp.RenameRemoteFile($existingFilepath,$newFilepath)
难道我的回答帮助? (因为我看到你问了一个新问题) –