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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capturing File Date Information

Status
Not open for further replies.

CHeighlund

Programmer
Jun 11, 2007
163
US
My boss has requested that I capture the date/time of creation for a file being drawn from a remote FTP server, for display in the program doing the ftp. (We've had instances where an older, outdated version of the file had been left on our box when the ftp process was run, causing problems.) Is there some method or component by which my program can capture the created/modified/accessed values of the file being sent right as it gets written to the system?
 
I'm not sure what you're looking to do, exactly...you want this stuff from the remote system (don't know what to tell you there)? If there's a question of whether the file should be overwritten or not, copy the file off of FTP to a temp file (most softwares I've seen download to temp anyway, so this isn't new), then check on the local side whether to overwrite, and when that's done, either copy the file or prompt.

Look up GetFileTime (it will be in the Windows unit) to get what you need to do this. FileTimeToSystemTime will also be of interest to you.

 
Open an ftp window, and enter
Code:
help dir
You'll find that the t option lets you specify which timestamp you want. So you could do
Code:
dir filename /t:c
to retrieve the creation date/time of filename. This will work for mdir (mls) too, I just can't remember for sure which one is for local and which is for remote. (Now that I think about it, the m commands are probably executed on the remote machine.)
 
I'll try to be more clear on this.

I'm supposed to make sure that the program I'm working with cannot accidentally claim an older copy of the file we are receiving via the ftp connection, since it will always have the same file name and location, both on the remote server and on our own target client box. The date stamps are the only real difference in them. I'm hoping for a way to read the 'created/modified' dates, the ones you see when you view the files properties, into the receiving program so that they can be displayed when the file is opened. Or, if they are the wrong dates (older than that day, since the 'modified' at least should be changed in an overwrite, if nothing else), so the program will not open the file, but toss out a warning message instead.
 
I'm hoping for a way to read the 'created/modified' dates, the ones you see when you view the files properties, into the receiving program so that they can be displayed when the file is opened.

If it's a local file, I already told you how to get the created/modified dates. But if it's remote, I don't know. That's the question of confusion on my part, do you want this information for the local file or the remote file?
 
I apologize; I somehow managed to miss your recommendations. I don't know how; I saw the first part of your post, but somehow overlooked the second. Again, I apologize for this. Thank you for pointing it out to me.
 
Are you reading any of the replies? If you're in ftp, what is it that the mdir command with the /t:c option doesn't do for you?
 
I was reading the replies, yes. Glenn9999's first response contained the answer to my question. I simply somehow managed to miss it when I came back to view the replies. Chalk it up to end-user(me) tunnel vision, I guess. Or end-user idiodicy, if you prefer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top