I am trying to download multiple files from the SFTP server.

I am having trouble with the GetFiles() Method, where it works in some instances, but not in others.

I Have a main directory, for example Lets call it Main, and it has 3 subdirectories under it, Dir1,Dir2 and Dir3. Each of those subdirectories have .dat files in them.

The following command is NOT downloading any of the .dat files:

client.GetFiles("/Main/*.dat", "c:\temp", SftpBatchTransferOptions.Recursive)

The following commnand IS downloading the .dat files (only from Dir1):

client.GetFiles("/Main/Dir1/*.dat", "c:\temp", SftpBatchTransferOptions.Recursive)

Why isnt the first example not getting any of the .dat files from any of the subdirectories. It does not seem like the recursive option is working properly?

I even tried using the SFTP Batch Transfer Sample provided with the download, with the same results.

asked 21 Oct '10, 21:03

Terry's gravatar image

Terry
262
accept rate: 0%


Try using SftpBatchTransferOptions.XCopy instead of SftpBatchTransferOptions.Recursive. It looks like that is the recursive mode you need!

SftpBatchTrasferOptions.Recursive: Operation is recursive. Files in the specified directory and all subdirectories are to be transferred. If wildcards are used, all files and subdirectories that match the wildcard are transferred (in case of subdirectories, this means that if a subdirectory name matches, all the files and sub-subdirectories in it are transferred).

SftpBatchTrasferOptions.XCopy: Operation is recursive. Files in the specified directory and all subdirectories are to be transferred. If wildcards are used, all files in the current directory (or any of its subdirectories) are transferred if they match the wildcard (this means that all subdirectories are traversed).

link

answered 22 Oct '10, 10:19

Lukas%20Pokorny's gravatar image

Lukas Pokorny ♦♦
2.4k28
accept rate: 31%

I tried using the Xcopy mode, it copies all of the folders as well, is there an option to only download the files?

(22 Oct '10, 12:29) Terry

This is a known limitation of this mode. Would you like to download all the files into a single folder? It looks like some kind of an ability to change the suggested target path for each item would be helpful. We will consider this for one of the next releases. In the meantime, the recommended workaround is to iterate through the downloaded directory tree, move all files to their desired location and remove unwanted directories.

(25 Oct '10, 11:49) Lukas Pokorny ♦♦

Yes, I would like for it to download to a single folder.

(26 Oct '10, 14:08) Terry
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×141
×20
×13
×2
×2

Asked: 21 Oct '10, 21:03

Seen: 861 times

Last updated: 25 Mar '11, 16:22