Reflection .NET API
Walkthrough / Other Automation Tasks / Transfer Files
In This Topic
    Transfer Files
    In This Topic

    This sample shows how to send a TSO file transfer from an IBM session.

    To send a TSO file transfer

    1. In Visual Studio, create a new Console Application project and add references for the following Reflection assemblies. (Depending on your version of Visual Studio, these can be found either on the .NET tab or under Assemblies | Extensions.)
      Attachmate.Reflection
      Attachmate.Reflection.Framework
      Attachmate.Reflection.Emulation.IbmHosts

    2. Replace all the code in the Program.cs file with the following code for the terminal you are using.
      Send a TSO file transfer
      Copy Code
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using Attachmate.Reflection.UserInterface;
      using Attachmate.Reflection.Framework;
      using Attachmate.Reflection.Emulation.IbmHosts;
      namespace FileTransfer
      {
          class Program
          {
              public void SendFileTransfer()
              {
                  //Get the last activated instance of Reflection
                  Application app = MyReflection.ActiveApplication;
      
                  //Make sure Reflection is running
                  if (app != null)
                  {
                      IFrame frame = (IFrame)app.GetObject("Frame");
                      IView view = (IView)frame.SelectedView;
                      IIbmTerminal terminal = (IIbmTerminal)view.Control;
                      Attachmate.Reflection.Emulation.IbmHosts.IFileTransfer fTransfer = terminal.FileTransfer;
                      fTransfer.XfrHostSys = HostSystem.Tso;
      
                      //transfer the test.txt file from the PC to the host using the IND$File protocol
                      fTransfer.INDSendFile(@"C:\Users\Public\Documents\test.txt", "bvtst02.test7.txt", INDFileTransferType.Ascii, FileExistsOption.Overwrite, true);
                  }
                  else
                  {
                     Console.WriteLine("Cannot find instance of Reflection");
                  }
              }
              static void Main(string[] args)
              {
                  Program app = new Program();
      
                  //Send the file transfer
                  app.SendFileTransfer();
              }
          }
      }
                             
      

    To test this project

    1. Create a file named test.txt in the Public Documents folder and add some data to the file.
    2. In Reflection, open the session you want to perform the transfer from and navigate to a TSO command line.
    3. In Visual Studio, press F5 to run this project.
    4. Verify that the session opens the File Transfer dialog box and transfers the test.txt file to the host.