views:

78

answers:

3

Hello,

I am using Visual Studio 2010 and I am trying to change the timen on my PC to 11 pm the ``day before yesterday. My question is can somebody tell me what statement that will allow ``me to output directly to DOS using C#.

Sorry for the poorly written question. I was trying to change the time to 11:50 two days ago. I am not familar with programming in Windows I have always used Linux. In linux I would execute my file from the command line and output to the command line. But using Visual Studio I was not sure if outputting to the command line would output to Visual Studio or MS DOS. If there is a way of changing the timecin this way I would appreciate it.

In command propt I entered date 28/07/2010 and it changed the date but when I entered Console.WriteLine("date 28/07/2010") into Visual Studio 2010 the time stayed the same. Is this statement not outputting to the command prompt.

Thanks for any help

A: 

Not sure what you are asking, but if you made a Console app, you'd use System.Console.WriteLine

http://msdn.microsoft.com/en-us/library/system.console.writeline.aspx

Lou Franco
+5  A: 
Console.WriteLine("Hello World!");

...assuming your application is started from the Command Line.

If you're trying to execute something from the command line (rather than outputing to the command line), then you want:

DateTime yesterdayAtEleven = 
    DateTime.Parse(DateTime.Now.AddDays(-1).Date.ToString("d") + " 11:00PM");
System.Diagnostics.Process.Start("date", yesterdayAtEleven.ToString());

System.Diagnostics.Process.Start

Justin Niessner
@Justin -- I am using a 64bit version of Windows 7 and it says file cannot be found. A Win32 Exception. Do you think this is because I am using a 64 bit system? Thanks
chrissygormley
+1  A: 

I believe this will work:

System.Diagnostics.Process.Start("time 23:59");
fearpi