0 votes
by (330 points)
edited

We have file names such as N10.AB10000.ABC.20.A123456 and they are in a directory such as ABC. I want to copy all files using a wildcard like so, N10.AB10000.ABC.20.* from the ABC directory. I have tried serval combinations in naming to try to get the files downloaded but I think the dot notation causes a problem with the download. All files I need are in the same ABC directory. I usually get "no datasets found". If I specify one whole file name then I get "Cannot find a file that was previously found." The one file gets copied but it thinks it is a directory in windows and is empty.

My code is:

ftp.ChangeDirectory("ABC");
ftp.GetFiles("N10.AB10000.ABC.20.*", "c:\test", FtpBatchTransferOptions.XCopy,   FtpActionOnExistingFiles.OverwriteAll);

3 Answers

0 votes
by (72.7k points)
edited
 
Best answer

Oh, mainframe is currently not supported, sorry. In the meantime you can do it like this:

ftp.ChangeDirectory("ABC");
FtpItemCollection list = ftp.GetList();
string[] files = list.GetFiles("N10.AB10000.ABC.20.*");
foreach (var file in files)
{
    FtpItem item = list[file];
    string targetPath = Path.Combine(@"c:\test", item.Name);
    ftp.GetFile(file, targetPath);
}
0 votes
by (72.7k points)
edited

I am not sure what do you mean by "the dot notation". Does it mean the remote directory separator is dot?

However it seems you are not using the latest version. Can you please try it with the latest trial version?

Also please note that the XCopy option is recursive and traverses all subdirectories. If the files are all in the same ABC directory (and not in subdirectories), the best way to download these files is:

ftp.ChangeDirectory("ABC");
ftp.Download("N10.AB10000.ABC.20.*", @"c:\test", TraversalMode.MatchFilesShallow, TransferMethod.Copy, ActionOnExistingFiles.OverwriteAll);
0 votes
by (330 points)
edited

By dot notation I mean the files all have several periods in the file name as I listed previously. These files are on a mainframe. After using the new version and your code I get:

Cannot download file ('./N10.AB10000.ABC.20.wer234'). Invalid data set name "./N10.AB10000.ABC.20.wer234". Use MVS Dsname conventions (501).

...