Page 1 of 1

Find vault location for a file under source control.

Posted: Fri Oct 08, 2010 7:23 am
by pjmartins
I have a project open in Visual Studio 2010 which is under source control via Vault. Is there a way to check out a file in this project via API based on its location on the local hard drive rather than its location in Vault? Or is there a way to find the repository location via API for a given working folder, in this case the folder which the project is located under on the local hard drive?

Re: Find vault location for a file under source control.

Posted: Fri Oct 08, 2010 9:45 am
by lbauer
If you have a working folder, you can call:

Code: Select all

ClientInstance.TreeCache.GetCorrespondingRepositoryPath(string diskPath)
which should give you a repository path.

Re: Find vault location for a file under source control.

Posted: Fri Oct 08, 2010 3:29 pm
by pjmartins
Function returns null each time. I used SetActiveRepositoryID to set the corresponding repository correctly. I also verified that the desired vault path of the file can be found:

Code: Select all

((VaultClientOperationsLib.VaultClientFolder)ClientInstance.TreeCache.Repository.Root.Folders[i]).Files[j]
Interestingly, when I try to call

Code: Select all

ClientInstance.GetWorkingFileName(VaultClientFile)
on the above VaultClientFile I get an object reference not set exception and calling GetWorkingFolder on the VaultClientFolder returns null. What else am I missing?

Re: Find vault location for a file under source control.

Posted: Thu Oct 14, 2010 3:21 pm
by lbauer
If the project is open in VS, then your best bet is to check it out in VS. We don't have an API which interacts with the Enhanced client, so any check out would not show up until the user refreshed the file status from within VS.

It might help us to know why you're wanting the check out a file outside of Visual Studio if Visual Studio is open.

Re: Find vault location for a file under source control.

Posted: Fri Oct 15, 2010 11:40 am
by pjmartins
Thank you, turns out my problem was I was trying to find the location in VS using different credentials which is why GetCorrespondingRepositoryPath did not work. Thanks again for your help.

Re: Find vault location for a file under source control.

Posted: Fri Oct 15, 2010 3:07 pm
by lbauer
Thanks for the update. That's good news. : )