i would like to get date and time of button event. Here is the code that is writing the input from textBox11 into text file when the button 5 is clicked.

Can anyone help me advice how to write the data and time into this text file when the button is click?

this->dateTimePicker1->Location= System::Drawing::Point(49,112);
this->dateTimePicker1->ValueChanges +=gcnew System::EventHand;er(this,&Form1::dateTimePicker1_ValueChange);
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e)
StreamWriter^ writeToFile=File::AppendText(openFileDialog1->FileName);
???????????dateTimePicker ?????????
commented: You've been around long enough to know how to use [code] tags. +0

Also scroll down the page and check the box "Disable Smilies" so that all those smilies do not appear.

All you probably need is DateTime::Now.ToString() to get the current time and date. I'm not sure why you would need the picker but if you want the user to specify the date you could get it by dateTimePicker1->Value.ToString() EDIT: Was typing during FBody's post but what he says is true. Learn to use the tags or else no more help on your posts.

Since you are writing managed code you will have to find out how to get the current system date/time. There are win32 api functions such as GetSystemTime(), but that is unmanaged code.

[edit]^^ posted before I saw this. Use Jonsca's suggestion.[/edit]