CSV download File Date Creation/Last Modified (1 Viewer)

sxschech

Registered User.
Local time
Yesterday, 21:39
Joined
Mar 2, 2010
Messages
793
This part of the question isn't vba, so not sure if the right forum, the results of the question are impacting the vba code to display what I thought is the file's creation date.

I periodically download a csv file and found code to display the creation date so that I could decide whether to get an updated csv file from the web based application. I assumed that the creation date was the one to use since there is the possibility that the existing downloaded file could be opened and edited. However, when I downloaded a new copy this morning, the file creation and modified date displays as follows: (using dos for example display purpose and not in my actual workflow process)

/T Controls which time field displayed or used for sorting timefield
C Creation
A Last Access


C:\Users\Downloads>dir rfis.csv /TC
Volume in drive C is OSDisk
Volume Serial Number is

Directory of C:\Users\Downloads

02/06/2019 01:37 PM 375,089 rfis.csv

C:\Users\Downloads>dir rfis.csv /TA
Volume in drive C is OSDisk
Volume Serial Number is

Directory of C:\Users\Downloads

03/04/2019 07:51 AM 375,089 rfis.csv
1 File(s) 375,089 bytes

How can this be since the file itself contains current data and was created at 7:50 am (clicked button to generate the csv output and 1 min later file saved to hard disk)

Is it because I forgot to delete the existing file before new one was downloaded and got saved as rfis (1).csv and then I deleted the existing rfis.csv and renamed the new one so it took on the old attributes?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 23:39
Joined
Feb 28, 2001
Messages
27,259
A rename modifies the file's attributes (specifically, the name attribute) and updates the date of last access. If that time corresponds to the time that you performed the rename, then all is as it should be.
 

sxschech

Registered User.
Local time
Yesterday, 21:39
Joined
Mar 2, 2010
Messages
793
updates the date of last access
I'm referring to Creation Date not date of last access as I understand that can change at any time.

Still doesn't make sense to me that if I delete a file from February and then rename a newly created file today, in March, it would change the date created from today back to February. Is there some other setting that is telling windows to keep deleted meta data and apply it to any new file that assumes the name of a previously deleted file?

Here are screen shots from a download I did today to test what happens with the dates. First dir was for yesterday's file along with today's file for Time and Creation Date (the date on yesterday's file should also be yesterday's date not Feb)

Second set of Dir is after deleting yesterday's file and renaming today's file. Once I did that, it too picked up the Feb date rather than today's date (which it had prior to being renamed)

C:\>dir \users\downloads\rfis*.csv /TA
Volume in drive C is OSDisk
Volume Serial Number is

Directory of C:\users\downloads

03/05/2019 01:03 PM 375,396 rfis (1).csv
03/04/2019 07:51 AM 375,089 rfis.csv
2 File(s) 750,485 bytes

C:\>dir \users\downloads\rfis*.csv /TC
Volume in drive C is OSDisk
Volume Serial Number is

Directory of C:\users\downloads

03/05/2019 01:03 PM 375,396 rfis (1).csv
02/06/2019 01:37 PM 375,089 rfis.csv
2 File(s) 750,485 bytes

---Delete rfis.csv
---Rename rfis (1).csv to rfis.csv


C:\>dir \users\downloads\rfis*.csv /TA
Volume in drive C is OSDisk
Volume Serial Number is

Directory of C:\users\downloads

03/05/2019 01:03 PM 375,396 rfis.csv
1 File(s) 375,396 bytes

C:\>dir \users\downloads\rfis*.csv /TC
Volume in drive C is OSDisk
Volume Serial Number is

Directory of C:\users\downloads

02/06/2019 01:37 PM 375,396 rfis.csv
1 File(s) 375,396 bytes
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 23:39
Joined
Feb 28, 2001
Messages
27,259
If the way that RFIS.CSV became RFIS (1).CSV was through editing that created a new copy based on the old file, the old file's creation date should have been retained but the date of last modification would be different.

I.e. if the (1) file was a modification of the original, the creation date wouldn't change.

However, if the file was NOT a modification but a complete re-gen, then damned if I know.

The next time you have the case where you have the original and a (1) copy, check all dates on BOTH files without deletion.
 

sxschech

Registered User.
Local time
Yesterday, 21:39
Joined
Mar 2, 2010
Messages
793
Not sure why my key word search didn't show this (or maybe I didn't see it?) when I originally went to locate a solution before posting. Anyway found out that this behaviour is intentional and how to get around it. Solution is to wait 15-20 seconds before rename. At least in my test of a newly downloaded file seems to work, so I'll mark as solved, we'll see what happens next month when I go through the actual process.

This is known as "tunnelling". See this KB article for further details. (The file is deleted for good. It's just the creation time and other metadata that is being carried across.)

https://stackoverflow.com/questions...plication-when-renaming-and-recreating-a-file

https://stackoverflow.com/questions...of-a-file-doesnt-change-when-while-is-deleted

Maybe that could also explain why I had trouble saving an excel file that already had the same name text wise, but needed to correct the case. Original version was myexcelfile.xlsx and revised copy saved as MyExcelfile.xlsx and nonetheless still displayed as myexcelfile.xlsx
 

Users who are viewing this thread

Top Bottom