Well, the mysteries of the file system. I have made another observation, which I make use of for quite some while:
I have done a small picture batch resizing utility for a website using gdiplusx and it writes files out with all uppercase file names. If I stroe them into another folder and then copy them back to the original, where files with the original capitalisation still exist, the files are overwritten, but the original capitalisation is kept. So it seems Windows is no erasing/writing the new file, but it is overwriting the file content resusing the old filename entry in the TOC (table of contents).
I haven't inspected what happens to file times, but I think they are updated. In my case the good side effect is I don't have to find out how to keep the file name capitalisation, I can get it back with this last step. What's interesting is, this only works, when copying the new files over the old ones, if I instead MOVE the new files, they are moved inclluding their all upper case file names.
And also in my tests of COPY TO I erased the file before copying, therefore I also didn't find the behavior you saw.
So finally, let's see what happens, if you erase vs not erase:
Code:
If !directory("d:\temp")
MkDir d:\temp
EndIf
If !directory("d:\temp\backup")
MkDir d:\temp\backup
EndIf
* first pass, no problem while erasing destination folder files
? "1st pass"
Cd d:\temp
Erase d:\temp\test.txt
* create file
StrToFile("test","d:\temp\test.txt")
? Fdate("d:\temp\test.txt",1)
Erase d:\temp\backup\test.txt
Wait '' timeout 3
* backup
Copy File d:\temp\test.txt to d:\temp\backup\test.txt
Erase d:\temp\test.txt
Wait '' timeout 3
* restore
Copy File d:\temp\backup\test.txt to d:\temp\test.txt
? Fdate("d:\temp\test.txt",1)
* second pass, no erasing now, just suppessing safety warning via SET SAFETY OFF
? "2nd pass"
Set Safety Off
Cd d:\temp
? Fdate("d:\temp\test.txt",1)
Wait '' timeout 3
* backup
Copy File d:\temp\test.txt to d:\temp\backup\test.txt
Wait '' timeout 3
* restore
Copy File d:\temp\backup\test.txt to d:\temp\test.txt
? Fdate("d:\temp\test.txt",1)
Set Safety On
Actually, for me that makes no difference. The first file creation datetime is preserved all the time, no matter if erasing destination folder files before copying or not.
I still assume this is not VFP but file system behavior.
Bye, Olaf.