控制台应用程序:
Dim myno As Integer = 1010
Console.WriteLine(Convert.ToString(myno))
Dim sw As New StreamWriter("filename.txt", True)
sw.Write(Convert.ToString(myno))
sw.Flush()
sw.Close()
Console.ReadLine()
Windows 应用程序:
Dim mm As New System.Diagnostics.Process
Dim info As New System.Diagnostics.ProcessStartInfo(Application.StartupPath & "\ConsoleApplication1.exe")
mm.StartInfo = info
mm.Start()
Dim f As New FileInfo(Application.StartupPath & "\filename.txt")
Dim s As StreamReader = f.OpenText
TextBox1.Text = s.ReadToEnd
If Not String.IsNullOrEmpty(TextBox1.Text) Then
mm.Kill()
End If
但是,控制台应用程序不会写入文本文件,Windows 应用程序会启动但不会关闭。