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->Margin=System::Windows::Forms::Padding(2);
this->dateTimePicker1->Name=L"dateTimePicker1";
this->dateTimePicker1->Size=System::Drawing::Size(179,20);
this->dateTimePicker1->TabIndex=10;
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);
writeToFile->WriteLine("{0}",textBox11->Text);
???????????dateTimePicker ?????????
writeToFile->Close();
}

Edited 6 Years Ago by fyp: n/a

Comments
You've been around long enough to know how to use [code] tags.

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

Edited 6 Years Ago by Ancient Dragon: n/a

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.

Edited 6 Years Ago by jonsca: n/a

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]

Edited 6 Years Ago by Ancient Dragon: n/a

This article has been dead for over six months. Start a new discussion instead.