home *** CD-ROM | disk | FTP | other *** search
/ ftp.tcs3.com / ftp.tcs3.com.tar / ftp.tcs3.com / DRIVERS / Audio / Office2010 / InfoPath.en-us / InfLR.cab / FL_CaptureOutputfromaConsoleApplication_sn_142534_ENU____.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Extensible Markup Language  |  2008-09-17  |  2KB  |  49 lines

  1. <?xml version="1.0"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3.   <CodeSnippet Format="1.0.0">
  4.     <Header>
  5.       <Title>Capture Output from a Console Application</Title>
  6.       <Author>Microsoft Corporation</Author>
  7.       <Description>Saves the output from a command console application to a string.</Description>
  8.       <Shortcut>appOutCap</Shortcut>
  9.     </Header>
  10.     <Snippet>
  11.       <References>
  12.         <Reference>
  13.           <Assembly>System.dll</Assembly>
  14.         </Reference>
  15.       </References>
  16.       <Imports>
  17.         <Import>
  18.           <Namespace>System</Namespace>
  19.         </Import>
  20.         <Import>
  21.           <Namespace>System.Diagnostics</Namespace>
  22.         </Import>
  23.         <Import>
  24.           <Namespace>Microsoft.VisualBasic</Namespace>
  25.         </Import>
  26.       </Imports>
  27.       <Declarations>
  28.         <Literal>
  29.           <ID>consoleExeFile</ID>
  30.           <Type>String</Type>
  31.           <ToolTip>Replace with file name of the console application to execute.</ToolTip>
  32.           <Default>"ConsoleApplication.exe"</Default>
  33.         </Literal>
  34.       </Declarations>
  35.       <Code Language="VB" Kind="method body"><![CDATA[Dim consoleApp As New Process
  36. With consoleApp
  37.     .StartInfo.UseShellExecute = False
  38.     .StartInfo.RedirectStandardOutput = True
  39.     .StartInfo.FileName = $consoleExeFile$
  40.     .Start()
  41.     .WaitForExit()
  42. End With
  43.  
  44. Dim output As String = consoleApp.StandardOutput.ReadToEnd()
  45.  
  46. ]]></Code>
  47.     </Snippet>
  48.   </CodeSnippet>
  49. </CodeSnippets>