从命令提示符重定向到文件 [英] from command prompt redirect to the file

查看:96
本文介绍了从命令提示符重定向到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从命令提示符处重定向文件.我得到正确的答案.但是我想从输出中获取某些内容.
我能怎么做?请通过更改代码将问题的答案发送给我.
下面发布的代码.


I am redirect the file from command prompt .I get correct answer.but i want to I want to some part from the output.
How can I do? please send me answer to my question with changes code.
the code posted below.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
namespace redirection
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo.FileName = "cmd ";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.Arguments = "/C ipconfig";
            p.StartInfo.RedirectStandardOutput = true;
            p.Start();
            string output = p.StandardOutput.ReadToEnd();
          
            p.WaitForExit();
            Console.WriteLine(output);
            Console.ReadLine();
        }
    }
}



o/p:
i give correct o/p. bt i want to only ip address of m/c other part is removed. please give me answer with changes code.

推荐答案

您是不是要将整个输出写入文件?如果是这样,请滤除您不想要的内容.并发布一些代码,这样您在做什么就更加明显了. (请在您的问题中添加代码,请勿将其发布为答案).
Do you mean you don''t want to write the entire output to the file? If so just filter out what you don''t want. And post some code so it''s more obvious what you are doing. (please add the code to your question, do not post it as an answer).


这篇关于从命令提示符重定向到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆