I’m having an odd issue following the $session.GetFiles command on the documentation page itself of GetFiles for .NET Assembly on Powershell.
When I take away the ‘ClientFolder’ in the source directory (first argument of $session.GetFiles), it will give it a timeout error “Timeout waiting for WinSCP to respond”. When I put the ‘ClientFolder’ back in, it will run and retreive the files needed within the subdirectories.
Why? Is there a recursion limit for subdirectories for it to look through? It has only a few levels of subdirectories between the requested FileMask files and the ClientFolder. I don’t see the problem.
try
{
# Connect
$session.Open($sessionOptions)
#
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "*Finance.xlsx"
# Download files
$transferOptions.AddRawSettings("ExcludeEmptyDirectories", "1")
$session.GetFiles("/CompanyName/HealthFiles/ClientFolder/*", "C:UsersUserNameDesktoptargetfolder", $False, $transferOptions).Check()
}
This will run and return files successfully, but I want to delete the ClientFolder level and run it. I will timeout and now download any files if I do so…
ABDA_analyst is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.