本文整理匯總了VB.NET中System.Diagnostics.Process.StandardInput屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET Process.StandardInput屬性的具體用法?VB.NET Process.StandardInput怎麽用?VB.NET Process.StandardInput使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Diagnostics.Process
的用法示例。
在下文中一共展示了Process.StandardInput屬性的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