.NET 응용 프로그램과 함께 명명 된 파이프 서버를 만들고 그 이름은 "TSPipe"입니다. 그런 다음 메모장을 열고 "\. \ pipe \ TSPipe"에 파일을 저장하십시오. 그러면 메모장에서 그 파이프에 쓴 내용을 읽을 수 있기를 원합니다.Windows에서 명명 된 파이프를 파일로 사용할 수 있습니까?
난 아직도 내 코드 명명 된 파이프 서버의 여기 NamedPipeServerStream을 처리하지만, 스레드에 대한 일반적인 로직을 일하고 있어요: 사전에 어떤 도움
public void PipeThread() {
var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
var rule = new PipeAccessRule(sid, PipeAccessRights.ReadWrite, AccessControlType.Allow);
var sec = new PipeSecurity();
sec.AddAccessRule(rule);
while (continuePipeThread) {
pipeStream = new NamedPipeServerStream("TSPipe", PipeDirection.In, 100, PipeTransmissionMode.Byte, PipeOptions.None, 0, 0, sec);
Program.Output.PrintLine("Waiting for connection...");
pipeStream.WaitForConnection();
Program.Output.PrintLine("Connected, reading...");
byte[] data = new byte[1024];
int lenRead = 0;
lenRead = pipeStream.Read(data, 0, data.Length);
string line = System.Text.Encoding.ASCII.GetString(data, 0, lenRead);
Program.Output.PrintLine(line);
pipeStream.Close();
pipeStream.Dispose();
}
}
감사합니다,하지만 난 당신을 드릴 것입니다 어떤 제안이 도움이되는지 아십시오!
감사합니다. 이 질문에 대한 답변입니다. 나는 IPC를 할 다른 방법을 찾아야 할 것 같아요. – Tim
그 텍스트를 보냅니 까? 그것은 나를 위해 작동하지 않습니다. (Win7, 상승 된'cmd') –