AnonymousPipeClientStream Constructor (String)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Initializes a new instance of the AnonymousPipeClientStream class with the specified string representation of the pipe handle.

Namespace:   System.IO.Pipes
Assembly:  System.Core (in System.Core.dll)

public AnonymousPipeClientStream(
	string pipeHandleAsString
)

Parameters

pipeHandleAsString
Type: System.String

A string that represents the pipe handle.

Exception Condition
IOException

pipeHandleAsString is not a valid pipe handle.

For constructors without a PipeDirection parameter, the default direction is In.

The following example demonstrates a way to send a string from a parent process to a child process by using anonymous pipes. In this example, an AnonymousPipeClientStream object is created in a child process.

using System;
using System.IO;
using System.IO.Pipes;

class PipeClient
{
    static void Main(string[] args)
    {
        if (args.Length > 0)
        {
            using (PipeStream pipeClient =
                new AnonymousPipeClientStream(args[0]))
            {

                Console.WriteLine("Current TransmissionMode: {0}.",
                   pipeClient.TransmissionMode);

                // Anonymous Pipes do not support Message mode.
                try
                {
                    Console.WriteLine("Setting ReadMode to \"Message\".");
                    pipeClient.ReadMode = PipeTransmissionMode.Message;
                }
                catch (NotSupportedException e)
                {
                    Console.WriteLine("EXCEPTION: {0}", e.Message);
                }

                using (StreamReader sr = new StreamReader(pipeClient))
                {
                    // Display the read text to the console
                    string temp;
                    while ((temp = sr.ReadLine()) != null)
                    {
                        Console.WriteLine(temp);
                    }
                }
            }
        }
        Console.Write("Press Enter to continue...");
        Console.ReadLine();
    }
}

Demand

for full trust for the immediate caller. This member cannot be used by partially trusted code.

.NET Framework
Available since 3.5
Return to top
Show: