Share via

Incorrect file creation date

Anonymous
2024-08-07T10:10:39+00:00

Hello I'm trying to create files with C++ but the creation time displayed is incorrect.Here's the code:[CODE]do
  {
    ++item;
    sprintf(pathDirFile,"%s/%s%03d.bmp",pathDir,file1,item); f1 = fopen(pathDirFile,"r");
    sprintf(pathDirFile,"%s/%s%03d.txt",pathDir,file2,item); f2 = fopen(pathDirFile,"r");
    if (f1) fclose(f1);
    if (f2) fclose(f2);
  } while (f1 != NULL || f2 != NULL);
    sprintf(pathDirFile,"%s/%s%03d.bmp",pathDir,file1,item); f1 = fopen(pathDirFile,"wb");
    sprintf(pathDirFile,"%s/%s%03d.txt",pathDir,file2,item); f2 = fopen(pathDirFile,"w");
  fprintf(f2,...);
  fwrite(buffer,1,sizeBuffer,f1);
  fclose(f2);
  fclose(f1);[/CODE]This code creates two files for me:- ****.bmp- ScalesXXX.txtwith XXX the following number of the files that exist in the directory.Everything works fine, except when I delete the files (it happens that I delete all but Image001.bmp and Scales001.txt) and I restart; He creates two files for me (Image002.bmp and Scales002.txt), but the creation date of Image002.bmp is wrong because it is older than the creation time (e.g. 10:15) while the creation date of Scales002.txt is correct (e.g. 11:38). If I delete these two files and restart, I get the same result (e.g. 10:15 for Image002.bmp and 11:39 for Image002.txt). The other files (Image003.bmp and Scales003.txt) created in a row always have a correct time. But if I delete all these files (Image002.bmp, Scales002.txt, Images003.bmp and Scales003.txt) and restart, I still have the same thing (e.g. 10:15 for Image002.bmp and 11:40 for Image002.txt). There must be one minute between the time I delete the files and the time I launch the application.I don't know how this is done and where this old time is memorized.Does anyone know where this old time is memorized please?Does anyone know how to get the correct creation time (the same for both files, i.e. the recent time) please?

Windows for home | Previous Windows versions | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2024-08-07T21:29:04+00:00

You are using C++ and getting that problem, which we do not handle here.

Was this answer helpful?

0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Christian 2B 18,536 Reputation points Volunteer Moderator
    2024-08-08T09:02:17+00:00

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-08-07T21:26:12+00:00

    The dates are not ceate by the programm C++. It's windows who create the date.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-08-07T12:26:12+00:00

    Hello I'm trying to create files with C++ but the creation time displayed is incorrect.Here's the code:[CODE]do
      {
        ++item;
        sprintf(pathDirFile,"%s/%s%03d.bmp",pathDir,file1,item); f1 = fopen(pathDirFile,"r");
        sprintf(pathDirFile,"%s/%s%03d.txt",pathDir,file2,item); f2 = fopen(pathDirFile,"r");
        if (f1) fclose(f1);
        if (f2) fclose(f2);
      } while (f1 != NULL || f2 != NULL);
        sprintf(pathDirFile,"%s/%s%03d.bmp",pathDir,file1,item); f1 = fopen(pathDirFile,"wb");
        sprintf(pathDirFile,"%s/%s%03d.txt",pathDir,file2,item); f2 = fopen(pathDirFile,"w");
      fprintf(f2,...);
      fwrite(buffer,1,sizeBuffer,f1);
      fclose(f2);
      fclose(f1);[/CODE]This code creates two files for me:- ****.bmp- ScalesXXX.txtwith XXX the following number of the files that exist in the directory.Everything works fine, except when I delete the files (it happens that I delete all but Image001.bmp and Scales001.txt) and I restart; He creates two files for me (Image002.bmp and Scales002.txt), but the creation date of Image002.bmp is wrong because it is older than the creation time (e.g. 10:15) while the creation date of Scales002.txt is correct (e.g. 11:38). If I delete these two files and restart, I get the same result (e.g. 10:15 for Image002.bmp and 11:39 for Image002.txt). The other files (Image003.bmp and Scales003.txt) created in a row always have a correct time. But if I delete all these files (Image002.bmp, Scales002.txt, Images003.bmp and Scales003.txt) and restart, I still have the same thing (e.g. 10:15 for Image002.bmp and 11:40 for Image002.txt). There must be one minute between the time I delete the files and the time I launch the application.I don't know how this is done and where this old time is memorized.Does anyone know where this old time is memorized please?Does anyone know how to get the correct creation time (the same for both files, i.e. the recent time) please?

    There is another Community for C++ Questions:

    https://learn.microsoft.com/en-us/answers/tags/314/cpp

    Was this answer helpful?

    0 comments No comments