setting my dateTime.Today

  • Thread starter Thread starter raulavi
  • Start date Start date
R

raulavi

vs 2008 c#
How to set my computer's date to +7 days from today's date...?

TIA
 
vs 2008 c#
How to set my computer's date to +7 days from today's date...?

TIA

you can run cmd.exe and execute date command using Process class.
 
how would you do it in c# ?

the following worked for me..

ProcessStartInfo startInfo = new
ProcessStartInfo("cmd.exe");
startInfo.UseShellExecute = false;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;

Process process = Process.Start(startInfo);

string command = String.Format("date\r\n{0}\r\n",
DateTime.Now.AddDays(7).ToString("MM-dd-yy"));
StreamWriter commandWriter = process.StandardInput;
commandWriter.WriteLine(command);
commandWriter.Flush();
commandWriter.Close();
process.Close();
 
thank you...I will give it a try.

parez said:
the following worked for me..

ProcessStartInfo startInfo = new
ProcessStartInfo("cmd.exe");
startInfo.UseShellExecute = false;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;

Process process = Process.Start(startInfo);

string command = String.Format("date\r\n{0}\r\n",
DateTime.Now.AddDays(7).ToString("MM-dd-yy"));
StreamWriter commandWriter = process.StandardInput;
commandWriter.WriteLine(command);
commandWriter.Flush();
commandWriter.Close();
process.Close();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top