Hello Guys,

I have a question regarding SFTP Upload. Here's the scenario:

In my local machine I have the following files to upload

Local Machine

C:\ForUpload\1\File_1_Full.zip
C:\ForUpload\1\File_1_Full.MD5
C:\ForUpload\2\File_2_Full.zip
C:\ForUpload\2\File_2_Full.MD5
C:\ForUpload\FileIndex.xml


Target Remote Location

/myserver


Question:
What function should I use to perform batch upload instead of specifying each file to upload I will just use patterns and then it will recursively loop through and find the pattern from source and upload to destination. like put("c:\ForUpload\\*.zip", "/myserver", SftpBatchTransferOptions.XCopy, SftpActionOnExistingFiles.OverwriteAll)


Expected Result:

/myServer/File_1_Full.zip
/myServer/File_1_Full.MD5
/myServer/File_2_Full.zip
/myServer/File_2_Full.MD5
/myServer/FileIndex.xml

asked 17 May '11, 20:34

jepoy's gravatar image

jepoy
333
accept rate: 0%

edited 18 May '11, 10:54

Lukas%20Matyska's gravatar image

Lukas Matyska ♦♦
90117


Unfortunately, this is too much complicated condition. It is not possible to do it by using wildcard patterns only.

Moreover you want to achieve a special task: transfer file without persisting original file hierarchy (you want to upload all files from different directories to a single target directory '/myServer' all together). This is not possible to do it in current version, but it is a reasonable behaviour, so we will probably add it to one of the future versions.

For now you have to split the task into multiple batch transfers. The given example can be achieved like this:

ftp.PutFiles("c:\ForUpload\1\File_*_Full.*", "/myServer", FtpBatchTransferOptions.Default);
ftp.PutFiles("c:\ForUpload\2\File_*_Full.*", "/myServer", FtpBatchTransferOptions.Default);
ftp.PutFiles("c:\ForUpload\FileIndex.xml", "/myServer", FtpBatchTransferOptions.Default);

This will transfer the 'c:\ForUpload\FileIndex.xml' file and all files (which name suits the pattern File_*_Full.*) from the 'c:\ForUpload\1' and 'c:\ForUpload\2' directories. Please note that this also transfer files like 'c:\ForUpload\1\File_5_Full.txt' (all file extensions meet the file name check).

link

answered 18 May '11, 11:35

Lukas%20Matyska's gravatar image

Lukas Matyska ♦♦
90117
accept rate: 28%

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
×16
×15
×5

Asked: 17 May '11, 20:34

Seen: 280 times

Last updated: 18 May '11, 11:35