本文整理汇总了VB.NET中System.Diagnostics.ProcessStartInfo.RedirectStandardInput属性的典型用法代码示例。如果您正苦于以下问题:VB.NET ProcessStartInfo.RedirectStandardInput属性的具体用法?VB.NET ProcessStartInfo.RedirectStandardInput怎么用?VB.NET ProcessStartInfo.RedirectStandardInput使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Diagnostics.ProcessStartInfo
的用法示例。
在下文中一共展示了ProcessStartInfo.RedirectStandardInput属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Main
' 导入命名空间
Imports System.IO
Imports System.Diagnostics
Imports System.ComponentModel
Namespace Process_StandardInput_Sample
Class StandardInputTest
Shared Sub Main()
Console.WriteLine("Ready to sort one or more text lines...")
' Start the Sort.exe process with redirected input.
' Use the sort command to sort the input text.
Using myProcess As New Process()
myProcess.StartInfo.FileName = "Sort.exe"
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.RedirectStandardInput = True
myProcess.Start()
Dim myStreamWriter As StreamWriter = myProcess.StandardInput
' Prompt the user for input text lines to sort.
' Write each line to the StandardInput stream of
' the sort command.
Dim inputText As String
Dim numLines As Integer = 0
Do
Console.WriteLine("Enter a line of text (or press the Enter key to stop):")
inputText = Console.ReadLine()
If inputText.Length > 0 Then
numLines += 1
myStreamWriter.WriteLine(inputText)
End If
Loop While inputText.Length <> 0
' Write a report header to the console.
If numLines > 0 Then
Console.WriteLine($" {numLines} sorted text line(s) ")
Console.WriteLine("------------------------")
Else
Console.WriteLine(" No input was sorted")
End If
' End the input stream to the sort command.
' When the stream closes, the sort command
' writes the sorted text lines to the
' console.
myStreamWriter.Close()
' Wait for the sort process to write the sorted text lines.
myProcess.WaitForExit()
End Using
End Sub
End Class 'StandardInputTest
End Namespace 'Process_StandardInput_Sample