I'm trying to send files under a folder to mainframe. I got the following error: "It is not easily possible to determine whether a file or directory exists at this server. Batch operations will not work." Why do I get this error?

Here is the code:

Ftp client = new Ftp();
client.Connect(ftpServerIP);
client.Login(ftpUserID, ftpPassword);
client.TransferType = FtpTransferType.Ascii;

client.PutFiles("c:\test\*", "//HRUNT.PER.ED.DE34.ACK.DDATA(+1)", FtpBatchTransferOptions.Recursive);

asked 15 Apr '11, 00:50

hhzhu's gravatar image

hhzhu
251
accept rate: 0%

edited 15 Apr '11, 13:54

Lukas%20Matyska's gravatar image

Lukas Matyska ♦♦
90117


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.

link

answered 15 Apr '11, 15:02

Lukas%20Matyska's gravatar image

Lukas Matyska ♦♦
90117
accept rate: 28%

edited 15 Apr '11, 15:11

Rebex%20KB's gravatar image

Rebex KB ♦♦
258519

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:

×152
×3

Asked: 15 Apr '11, 00:50

Seen: 1,015 times

Last updated: 15 Apr '11, 15:11