我要完成的工作是在表单上有一个文本框控件和一个按钮控件。当单击文本框控件中输入的任何内容时,我想将该数据发送到控制台应用程序,该应用程序进而创建一个文本文件。我大部分时间都在工作,但我无法获取从 Web 应用程序发送的数据。我该如何做到这一点?这是我到目前为止所拥有的。
这是我要发送到控制台应用程序的子程序:
Public Sub send_to_console()
Dim file As String = "C:\inetpub\wwwroot\TestConsoleApp\TestConsoleApp\bin\Debug\TestConsoleApp.exe"
Dim info As ProcessStartInfo = New ProcessStartInfo(file, TextBox1.Text)
Dim p As Process = Process.Start(info)
End Sub
控制台应用程序代码:
ublic Sub Main(ByVal args As String)
Dim w As StreamWriter
Dim filepath As String = "C:\xml_files\testFile.txt"
Dim new_string As String
new_string = "This has been completed on " & Date.Now
If args = "" Then
new_string = "No data entered on: " & Date.Now
Else
new_string = args & " " & Date.Now
End If
If System.IO.File.Exists(filepath) Then
File.Delete(filepath)
End If
w = File.CreateText(filepath)
w.WriteLine(new_string)
w.Flush()
w.Close()
End Sub
目前我收到一个错误:没有可访问的 Main
'#######################EDITS###########
Dim file As String = "C:\inetpub\wwwroot\TestConsoleApp\TestConsoleApp\bin\Debug\TestConsoleApp.exe"
Dim info As ProcessStartInfo = New ProcessStartInfo(file, TextBox1.Text)
info.UseShellExecute = False
Dim p As Process = Process.Start(info)