Exemplo n.º 1
0
        static void serverThread()
        {
            NamedPipeServerStream pipeServer = new NamedPipeServerStream("testpipe", PipeDirection.InOut, NumThread);

            int threadId = Thread.CurrentThread.ManagedThreadId;

            pipeServer.WaitForConnection();//等待连接

            Console.WriteLine("客户端线程id:[{0}].", threadId);
            try
            {
                StreamString s = new StreamString(pipeServer);

                s.WriteString("我是服务");
                string file = s.ReadString();

                ReadFileToStream filereader = new ReadFileToStream(file, s);

                Console.WriteLine("Reading file: {0} on thread[{1}] as user: {2}.",
                                  file, threadId, pipeServer.GetImpersonationUserName());

                pipeServer.RunAsClient(filereader.Start);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
 public ReadFileToStream(string f, StreamString sstring)
 {
     file = f;
     ss   = sstring;
 }