Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Ok, but I suppose you set the fileName to FTP14*.x.

As the example, you refer to, calls session.FileExists(remotePath) before calling session.GetFiles(remotePath, localPath), it fails. You probably do not want the check at all. Just remove it.

Also note that the example does not use wildcards, nor mentions anywhere that you can use wildcards for it.

Anyway this is really just an code sample. If you want its functionality, including wildcard support, use the simple code mentioned in comments:
// You can achieve the same using:

session.SynchronizeDirectories(
    SynchronizationMode.Local, localPath, remotePath, false, false, SynchronizationCriteria.Time,
    new TransferOptions { IncludeMask = fileName }).Check();
JasonRkr

Martin,

I'm using the PowerShell sample code provided at https://winscp.net/eng/docs/library_session_getfiles#example. I've just changed the variables to match my server.

if ($download)

{
    # Download the file and throw on any error
    $session.GetFiles($remotePath, $localPath).Check()
    Write-Host "Download to backup done."
}


Jason
martin

Re: Error Downloading File - Wildcard Issue?

For download (Session.GetFiles, note the plural) you can indeed use wildcards. But from the log, I suppose you are using Session.FileExists (note the singular) first, that does not support wildcards:
https://winscp.net/eng/docs/library_session_fileexists
JasonRkr

Error Downloading File - Wildcard Issue?

Group,

I'm receiving a file not found error when trying to download a file using a wildcard in the name. However, when I use the full file name it works without issue. Below is a section of the DebugLog file in the hopes it may provide additional detail. Also, the server I'm downloading from is running AIX 6.

<session xmlns="https://winscp.net/schema/session/1.0" name="qcupload@vm6klab1" start="2013-08-14T21:07:07.742Z">
<group name="open -hostkey=&quot;ssh-rsa 2048 0e:2b:76:24:bf:50:e7:29:f5:01:2b:e6:59:16:ea:10&quot; -timeout=15 sftp://qcupload:***@vm6klab1" start="2013-08-14T21:07:08.539Z">
</group>
<group name="stat -- &quot;/U/softprint/FTP14*.x&quot;" start="2013-08-14T21:07:08.664Z">
<stat>
<filename value="/U/softprint/FTP14*.x" />
<result success="false">
<message>Can't get attributes of file '/U/softprint/FTP14*.x'.</message>
<message>No such file or directory.
Error code: 2
Error message from server: No such file
Request code: 7</message>
</result>
</stat>
<failure>
<message>Can't get attributes of file '/U/softprint/FTP14*.x'.</message>
<message>No such file or directory.
Error code: 2
Error message from server: No such file
Request code: 7</message>
</failure>
</group>
<group name="exit" start="2013-08-14T21:07:08.789Z">
</group>
</session>

Thank you,

Jason