Show Contents / Index / Search

Create a Session from an Existing Session File

This sample program uses CreateControl() to create a new session based on a saved session file. The session does not have a view associated with it and is therefore not visible. (For other ways to get terminal sessions, see Terminal and View Objects.)

To create an "existing" session

  1. Start Reflection 2008, create a session document, and connect to the host.
  2. Name, save, and then close the session document, but leave Reflection 2008 running.
  3. In Visual Studio, create a new Console Application project. In the New Project dialog box, type "Get Existing Session" in the Name field. Select the Create directory for solution box, click Browse to select your API projects folder (for example, C:\MyProjects), and then click OK.
  4. In Solution Explorer, add the class assemblies. (For instructions, see Create an API Project.)
  5. Copy the code from one of the following programs:

    Create Session From Existing Session File (IBM)

    Create Session From Existing Session File (OpenSystems)

  6. In Visual Studio, paste the code to the Program.cs tab, replacing all existing code.
  7. In the code, change the parameter for reflectionApplication.GetControlsByFilePath to the complete path of your saved session document. Between the quotation marks, type the path exactly as it appears, including the drive letter (for example, C:\), any spaces, and the filename and extension of the session document.
  8. Build the application (Build > Rebuild Solution) and then run it (Debug > Start Without Debugging).

    A Windows command console containing a line of extracted text should appear.