And again with a question! I need to change the date of creation of the file selected by the user. The program is compiled, but unfortunately the creation date does not change. The code adapted for the console is correctly executed and eventually changes the date the file was created ... A piece of code below. Tell me what is the reason?
string naka = SystemToStl (nama); // name of the selected file, obtained using OpenFileDialog
LPCSTR lpMyString = naka.c_str(); SYSTEMTIME lf; FILETIME ft; OFSTRUCT of; HANDLE hFile=(HANDLE)OpenFile(lpMyString, &of, OF_CREATE); if(!hFile) { MessageBox::Show("ERRROR","Справка", MessageBoxButtons::OK);} ::GetFileTime(hFile, &ft, NULL, NULL); FileTimeToSystemTime(&ft, &lf); String^ strok = ""; unsigned short vert = 0; // WORD years, mesiac, den, chas, minuta, secunda; vert = Convert::ToInt32(textBox2->Text); lf.wYear=vert; vert = Convert::ToInt32(textBox3->Text); lf.wDay=vert; vert = Convert::ToInt32(textBox4->Text); lf.wMonth=vert; vert = Convert::ToInt32(textBox5->Text); lf.wHour=vert; vert = Convert::ToInt32(textBox6->Text); lf.wMinute=vert; vert = Convert::ToInt32(textBox7 ->Text); lf.wSecond=vert; SystemTimeToFileTime(&lf, &ft); SetFileTime(hFile, &ft, NULL, NULL); CloseHandle(hFile);
SetFileTime. See docs.microsoft.com/en-us/windows/desktop/api/fileapi/… - Herman BorisovSystemTimeToFileTimereturns, there may also be a problem. - freimstat()function? - NewView