WinSCP .NET does not support passing literal file names without mask interpretation
There's no API in WinSCP .NET assembly to pass a literal file name, without interpreting it as a file mask.
Is there a way to copy a single file whose name includes wildcard characters (e.g., [Hospital1]_0001.txt) without WinSCP listing the entire directory?
WinSCP treats [ and ] as wildcard characters, so instead of copying the file directly, it attempts to resolve the pattern and ends up listing the entire directory. The problem is that this folder contains over one million files, so the directory listing takes around 40 minutes and triggers a timeout exception—even though I only need to copy a single file.
This does not happen with files like Test.txt, but all required files in my case include square brackets. I also tried RemotePath.EscapeFileMask(fileName), but it didn't solve my issue.
I tried but it didn't work either.
See:
https://stackoverflow.com/questions/79845134/how-can-i-copy-a-single-file-whose-name-includes-wildcard-characters-without-lis#comment140902408_79845134
Is there a way to copy a single file whose name includes wildcard characters (e.g., [Hospital1]_0001.txt) without WinSCP listing the entire directory?
session.GetFileToDirectory("/IDEData/[Hospital1]_0001.txt", @"C:\IdeData\", true, null);WinSCP treats [ and ] as wildcard characters, so instead of copying the file directly, it attempts to resolve the pattern and ends up listing the entire directory. The problem is that this folder contains over one million files, so the directory listing takes around 40 minutes and triggers a timeout exception—even though I only need to copy a single file.
This does not happen with files like Test.txt, but all required files in my case include square brackets. I also tried RemotePath.EscapeFileMask(fileName), but it didn't solve my issue.
I tried
session.GetFiles(session.EscapeFileMask("/var/pathTo/[Hospital1]_001.txt"), @"C:\somewhere\*").Check();See:
https://stackoverflow.com/questions/79845134/how-can-i-copy-a-single-file-whose-name-includes-wildcard-characters-without-lis#comment140902408_79845134