Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.8k views
in .NET FTP by (280 points)
I'm new to the product.
I need to account for potentially multiple files (I can successfully download one using DownloadFile), but our partner doesn't explicitly allow remote locations. Instead we are provided a batchid. A command to download a batch would be similar to:

get "ID=myFTPID BID='PGP ABC RE1234 TX12345' ONEBATCH=Y" newLocalFileName

I execute this using ExFTPConnection.InvokeFTPCommand(cmd, null), and it produces no errors, but doesn't pull anything either. Is there a way (including a better way) to do this using ExFTPConnection object?

DownloadMultiple only allows the use of a RemoteDir param, which I cannot provide.

Thank you!

5 Answers

0 votes
by (51.6k points)
InvokeFTPCommand won't work because it doesn't open data channels. Have you tried using the DownloadFile method as follows:
ftpConnection.DownloadFile("ID=myFTPID BID='PGP ABC RE1234 TX12345' ONEBATCH=Y", newLocalFileName);

or possibly
ftpConnection.DownloadFile("\"ID=myFTPID BID='PGP ABC RE1234 TX12345' ONEBATCH=Y\"", newLocalFileName);


If so, what happened?

- Hans (EnterpriseDT)
0 votes
by (280 points)
Thank you for the response! Really appreciated.
There are 2 files available, but when I run the code below I only receive one, or is it overwriting the preceding with the same filename?

string batchId = "$$ ID=myFTPID BID='PGP ABC RE1234 TX12345' ONEBATCH=Y";
ftpConnection.DownloadFile( this.localDir + "\\test_0428.txt" , batchId );

Is there any facility for this to re-name the second/subsequent files?

Thanks!
0 votes
by (51.6k points)
I'm not sure I quite understand you. DownloadFile will only ever download a single file at a time. If there are two files then you will need to call DownloadFile twice - once for each file-name.

- Hans (EnterpriseDT)
0 votes
by (280 points)
Yes, it is a bit confusing! Mostly to do with the security implemented at our partner's ftp site. I now have a few more details which helps. ->
The files at the remote location are all named the same (the batchid). If there is only one file (99.9% of the time) I'm good. Once downloaded, the file is marked as unavailable for download.
If more than one file is available, I need to find out how many files are available, then use the BATCH=Y command 'x' times (for each file available).
If I do a FTPClient.Dir(location, true) I can at least work with the full file list to determine how many times to call DownloadFile.
But then that is neither fish nor fowl is it?
0 votes
by (162k points)
That's simple enough then. Just call DownloadFile multiple times, with a different name for the local file each time, e.g.

ftpConnection.DownloadFile( this.localDir + "\\test_0428.txt.1" , batchId );
ftpConnection.DownloadFile( this.localDir + "\\test_0428.txt.2" , batchId );

etc

Categories

...