如何检查stdin的管道数据 [英] how to check stdin for piped data
本文介绍了如何检查stdin的管道数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够将数据从stdin传输到我的prog或从文件中获取数据。
如果我尝试使用
Hi,
I would like to be able to either pipe data into my prog from stdin or get data from a file.
If I try to check by using
展开 | 选择 | Wrap | 行号
推荐答案
如果是WinForm应用程序,我建议您对按键事件作出反应。
这样,只要按下任何键,你就可以继续你想要的任何东西。
它必须是一个控制台应用吗?
If it were a WinForm app I would suggest reacting to the keypress event.
That way as soon as any key is pressed you can move on to whatever you like.
Does it have to be a console app?
这是否work?
Console.OpenStandardInput()。Length
Does this work?
Console.OpenStandardInput().Length
感谢您的回复。
>它必须是一个控制台应用程序吗? - 对按键事件作出反应
是的,它只是一个过滤器应用程序。
我认为你可以在Console应用程序中获得按键事件但是
我不认为管道数据会导致按键事件和
程序不会接受任何Q& A用户输入。
程序将过滤浮点数流。
我希望用户成为能够提供流:
- 在命令行上输入
。 。例如:echo1.2334 2.345 3.456 | myprog
- 或者来自用户提供的文件arg [0]
如果两者都没有提供,编程将创建它自己的样本数据。
我无法从Console.OpenStandardInput()。长度中获取任何内容
Thanks for your replies.
> Does it have to be a console app? - reacting to the keypress event
Yes it is just a filter app.
I think you CAN get keypress events in a Console app but
I don''t think piped data would cause a keypress event and
the program will not be taking any Q&A user input.
The program will filter a stream of floating point numbers.
I wanted the user to be able to supply the stream either:
- piped in on the command line
. . eg: echo "1.2334 2.345 3.456 " | myprog
- or from a file supplied by user as arg[0]
If neither is supplied the prog will create it''s own sample data.
I couldnt get anything out of "Console.OpenStandardInput().Length"
展开 | 选择 | 换行 | 行号
这篇关于如何检查stdin的管道数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文