How do I get the last modified date of a file?

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

Post Reply
HMortlock
Posts: 2
Joined: Fri Oct 18, 2013 5:03 am
Location: Gloucestershire, UK

How do I get the last modified date of a file?

Post by HMortlock » Fri Oct 18, 2013 5:35 am

We are running an extract from the Vault Database and comparing it with files on our network to check the lastest versions of exe and dll files are in SourceGear Vault database.

We are currently getting a collection of VaultHistoryItems and using the VaultHistoryItem.TxDate as this appears to be the last checked in date.

On the Client I can see in the 'File Properties' 'General' tab - a 'Latest In Repository' - 'Modified date'. We want to extract this date but I'm not sure how to get hold of it in the API?

Any help appreciated.

Thanks :)

jclausius
Posts: 3706
Joined: Tue Dec 16, 2003 1:17 pm
Location: SourceGear
Contact:

Re: How do I get the last modified date of a file?

Post by jclausius » Fri Oct 18, 2013 8:35 am

Within the API, after login and setting the active repository id, do you see a ServerOperations.client.ClientInstance.TreeCache.Repository.Root object? This will member variable will contain a tree like structure (with folders) full of VaultClientTreeObjects. Each object within the tree will have a VaultClientTreeObject.ModifiedDate for the date the file was last modified and a VaultClientTreeObject.TxDate for the date of the transaction which created that version of the object.

So, if you login, set the active repository id, call Refresh() on ClientInstance to make sure your local repository tree is the latest, walking the tree should provide the information that you need.

HTH
Jeff Clausius
SourceGear

HMortlock
Posts: 2
Joined: Fri Oct 18, 2013 5:03 am
Location: Gloucestershire, UK

Re: How do I get the last modified date of a file?

Post by HMortlock » Mon Oct 21, 2013 9:35 am

Thanks for your help Jeff,

The 'ServerOperations.client.ClientInstance.TreeCache.Root' object seems to return a VaultClientFolder rather than the VaultClientTreeObject, so I've used the FindTreeObjectRecursive method on this and its given me the VaultClientTreeObject and the modified date.

Wouldn't have had a clue without your guidance so thanks. :D

jclausius
Posts: 3706
Joined: Tue Dec 16, 2003 1:17 pm
Location: SourceGear
Contact:

Re: How do I get the last modified date of a file?

Post by jclausius » Mon Oct 21, 2013 1:08 pm

NP. Glad it worked. FWIW, VaultClientFolder and VaultClientFile are subclasses of VaultClientTreeObject.
Jeff Clausius
SourceGear

Post Reply