控制台输出到字符串
我正在开发一个小应用程序,它需要在字符串中设置 dsquery 和 dsget 的结果进行清理(替换空格和其他不需要的字符)。我可以使用 ReadToEnd 显示流的结果 - 但似乎找不到任何将其放入字符串的信息。
VB.net - Visual Basic 2010
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim p As New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.CreateNoWindow = True
p.StartInfo.FileName = "program"
p.StartInfo.Arguments = "lots here"
p.StartInfo.RedirectStandardOutput = True
p.Start()
Dim reader As StreamReader = p.StandardOutput
p.WaitForExit()
MsgBox(reader.ReadToEnd)
End Sub
I'm working on a little app that requires the results of a dsquery and dsget set in a string for clean up (replacing spaces and other not needed characters). I can display the results of the stream with ReadToEnd - but can't seem to find anything on getting it into a string.
VB.net - visual basic 2010
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim p As New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.CreateNoWindow = True
p.StartInfo.FileName = "program"
p.StartInfo.Arguments = "lots here"
p.StartInfo.RedirectStandardOutput = True
p.Start()
Dim reader As StreamReader = p.StandardOutput
p.WaitForExit()
MsgBox(reader.ReadToEnd)
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只写
而不是最后一行。
如果这没有帮助,那么我建议您查看这篇文章:
http://www .codeproject.com/KB/threads/launchprocess.aspx
just write
instead of the last line.
if that doesn't help, then I suggest you check out this article:
http://www.codeproject.com/KB/threads/launchprocess.aspx