I am very new to C++-CLI and recently finished working on my first "official" application. I was advised to create application logs to track its effectiveness. When the form opens, the application tracks the date, time, and PC username and writes it to a text file.
That works well, though I am having trouble displaying an IP Address. I receive an error "Type name is not allowed" on (System::Net::IPAddress).
lastlineoffile += ( std::string((char *)Marshal::StringToHGlobalAnsi(DateTime::Now.ToString("MM-dd-yy")).ToPointer()) + " " +
std::string((char *)Marshal::StringToHGlobalAnsi(DateTime::Now.ToString("HH:mm")).ToPointer()) + " " +
//std::string((char *)Marshal::StringToHGlobalAnsi(System::Net::IPAddress).ToPointer()) + " " +
std::string((char *)Marshal::StringToHGlobalAnsi(System::Environment::UserName).ToPointer()) );
std::cout << "last line to be added: " << lastlineoffile << std::endl;
file << lastlineoffile.c_str();
//saves usage text file
file.close();
Additionally, I would like to record the time the application is exited. The previous perimeters are all recorded at the start of the application. I figure there would have to be a pointer that references the time off when the application closes. Any insight on how this would be accomplished would be appreciated.
Thanks