如何使用命令提示符获取包含毫秒的净时间 [英] How to get net time including milliseconds using command prompt

查看:130
本文介绍了如何使用命令提示符获取包含毫秒的净时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用命令提示符获取净时间。在CMD内部,我使用净时间,它返回结果当前时间......上午9:53:45,没有毫秒。如何包含毫秒数?



仅供参考,我将检索使用C#代码获得的结果。以下是我在C#中的代码:



 使用(流程p =  new  Process())
{
p.StartInfo.UseShellExecute = false ;
p.StartInfo.RedirectStandardOutput = true ;
p.StartInfo.CreateNoWindow = true ;
p.StartInfo.FileName = ConstantReference.General.Net;
p.StartInfo.Arguments = @value;
p.Start();
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd(); // 此处的结果
}





在字符串输出内部,由于返回的结果也没有毫秒也没有毫秒。感谢任何输入。

解决方案

尝试 string output = p.StandardOutput.ReadToEnd()++ DateTime.Now.MilliSeconds;

Hi, I am trying to get the net time using command prompt. Inside the CMD, I use "net time" and it return me the result "Current time at......9:53:45 AM" without the milliseconds. How can I include the milliseconds?

FYI, I will retrieve the results I get using C# codes. Below are my codes in C#:

using (Process p = new Process())
        {
         p.StartInfo.UseShellExecute = false;
         p.StartInfo.RedirectStandardOutput = true;
         p.StartInfo.CreateNoWindow = true;
         p.StartInfo.FileName = ConstantReference.General.Net;
         p.StartInfo.Arguments = @value;
         p.Start();
         p.WaitForExit();
         string output = p.StandardOutput.ReadToEnd(); //result here
        }



Inside string output, it dont have milliseconds due to the result returned do not have milliseconds also. Any input is appreciated.

解决方案

Try string output = p.StandardOutput.ReadToEnd() + " " + DateTime.Now.MilliSeconds;


这篇关于如何使用命令提示符获取包含毫秒的净时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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