You got the error because Batch operations are not supported with Mainframe. Only supported methods are PutFile
, GetFile
and GetList
.
You can write your own PutFiles method for example like this:
private static void PutFiles(Ftp client, string localPath, string fileMask, string remotePath)
{
if (string.IsNullOrEmpty(fileMask))
fileMask = "*";
string[] localFiles = Directory.GetFiles(localPath, fileMask);
foreach (string localFile in localFiles)
{
string name = Path.GetFileName(localFile);
string remoteFile = RemotePathCombine(remotePath, name);
client.PutFile(localFile, remoteFile);
}
string[] localDirectories = Directory.GetDirectories(localPath);
foreach (string localDirectory in localDirectories)
{
string name = Path.GetFileName(localDirectory);
string remoteDirectory = RemotePathCombine(remotePath, name);
PutFiles(client, localDirectory, fileMask, remoteDirectory);
}
}
private static string RemotePathCombine(string remotePath, string name)
{
return string.Format("{0}/{1}", remotePath.TrimEnd('/'), name);
}
You can use it like this:
Ftp client = new Ftp();
client.Connect(ftpServerIP);
client.Login(ftpUserID, ftpPassword);
client.TransferType = FtpTransferType.Ascii;
PutFiles(client, @"c:\test", "*.xml", "//HRUNT.PER.ED.DE34.ACK.DDATA(+1)");
Please note the method RemotePathCombine
. You have to write your own implementation of it according to your Mainframe. Given implementation is for common FTP server.