Named Pipes with .NET?

This is a discussion on Named Pipes with .NET? within the C# Programming forums, part of the General Programming Boards category; I'm trying to create a named pipe with .NET. With: System.IO.FileStream fs = new FileStream( "\\.\pipe\name", FileMode.Truncate, FileAccessWrite, FileShare.Read, 0x8000 ...

  1. #1
    michl
    Guest

    Named Pipes with .NET?

    I'm trying to create a named pipe with .NET.

    With:
    System.IO.FileStream fs = new FileStream( "\\\\.\\pipe\\name",
    FileMode.Truncate, FileAccessWrite, FileShare.Read, 0x8000 );

    after that, an System.IO.FileNotFountException occures.

    Has anybody an idea how to create and use Named Pipes in .NET, with C#?

    Thanks in advance!
    Michl

  2. #2
    Registered User dragunsflame's Avatar
    Join Date
    Jan 2003
    Posts
    8
    Assuming that the name of the file was \\name:

    Make sure that the file is already created. FileMode.Truncate will only open an existing file. If not, filenotfound exception is thrown. Try using something like FileMode.Open or FileMode.Append.

    I hope that works.

  3. #3
    Michl
    Guest
    Hello dragunsflame!

    I've tested it with FileMode.Create and FileMode.CreateNew, but no one workes!

    I think the problem lies in the Pipe path ("\\\\.\\pipe\\..."). The path is not a usually know "File Path". Using System.IO.DirectoryInfo returnes named Pipes of your System...

    Code:
    System.IO.DirectoryInfo di = new 
       System.IO.DirectoryInfo("\\\\.\\pipe" );
    FileInfo[] afi = di.GetFiles();
    
    foreach( FileInfo fi in afi )
    {
       Console.WriteLine( fi.ToString() );
    }
    Perhaps someone gets an idea...

    Thanks
    Michl

    >Assuming that the name of the file was \\name:
    >
    >Make sure that the file is already created. FileMode.Truncate will >only open an existing file. If not, filenotfound exception is >thrown. Try using something like FileMode.Open or >FileMode.Append.
    >
    >I hope that works.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Replies: 2
    Last Post: 04-22-2008, 01:07 PM
  3. Replies: 2
    Last Post: 04-19-2008, 01:06 AM
  4. Deletion of open named pipes
    By sparkymat in forum Linux Programming
    Replies: 4
    Last Post: 11-07-2007, 10:46 AM
  5. Visual J#
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-08-2001, 03:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21