Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy a file to another file location AND change the Creation Date on the new file to the Current dat 1

Status
Not open for further replies.

PatMcLaughlin

Programmer
Dec 10, 2010
97
US
We have a fax program running on 2 computers simultaneously that uses a folder (we will say f:\FaxFiles\) to hold the .pdf and .fmf files used. We have a 'house keeping' program that constantly scans this file folder for files older than 14 days. This has worked for years. Now all at once, we have a need to send 90+ faxes to our vendors and dealers multiple times in a 45 day window. The program will normally just copy the faxletter.pdf from folder f:\Holding to f:\FaxFiles. The fax program uses it and goes on. With the initial fax now being over 14 days old, when it is copied in, (it retains the 'Creation Date' of the original file) within 3 seconds, it is gone. I need a way to copy the .pdf file, yet change the creation date to current date.
Any ideas?
 
STRTOFILE(FILETOSTR("f:\Holding\faxletter.pdf"),"f:\FaxFiles\faxletter.pdf")

Bye, Olaf.
 
You can use the function setfiletimes found in vfp2c32.fll
( )
it allows you to set creation time, last modified, and last accessed.

From the help file:

Code:
SetFileTimes(cFileName, tCreationTime [, tLastAccessTime [, tLastWriteTime [, bUTCTimes]]])

where tcreationTime is a datetime value.


Marco
 
STRTOFILE(FILETOSTR("f:\Holding\faxletter.pdf"),"f:\FaxFiles\faxletter.pdf")

FWIW, this is the way I'd do it too, given the requirements on the table.
 
for Olaf's suggestion, which i would use as well, you might need:
oSafety = set("Safety")
set safety off
filetosr(...)
set safety &oSafety

otherwise, you will get the confirmation override dialogue box

Ez Logic
Michigan
 
As far as I understand the f:\FaxFile normally doesn't have the file copied into it, but it could be the case, true. The default for the nFlags Parameter of STRTOFILE will make it overwrite, but to prevent a confirmation dialogue set safety off temporarily, yes.

To copy with FILETOSTR and STRTOFILE creates a new file and so it has the current datetime. It also stripes off permissions and attributes, etc, and of course the current user is the owner of the new file, but that shouldn't matter. If it does, the other solutions should be applied to the file in its source location f:\Holding\ before copying it. You may also use foxtouch of foxtools.fll (FYI that's not related to any Samantha).

Bye, Olaf.
 
Olaf, This confirms it, YOU ARE A GENIUS!!!!! Just what I needed!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top