Read file contents

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

Moderator: SourceGear

Post Reply
behold
Posts: 43
Joined: Fri Jan 06, 2006 1:00 pm

Read file contents

Post by behold » Tue Jul 01, 2008 12:36 pm

How do i read file contents in Vault? I am using Vault API 3.1.2.

shannon

Post by shannon » Tue Jul 01, 2008 2:15 pm

Can you clarify what you are trying to do? Are you wanting to do a get?

behold
Posts: 43
Joined: Fri Jan 06, 2006 1:00 pm

Read File Contents

Post by behold » Tue Jul 01, 2008 2:53 pm

My users would like to search the contents of files (Last Version) in Vault for user-defined strings. The only way to accomplish this that I know of at the moment, is to copy the file from Vault (GetLatestVersion) to the users hard drive and open the file there and perform the search. We have a rather large repository and a full repository search by this process cannot be pretty. I have a utility that can search Vault folder paths and file names. I would like to extend the search to include file contents if possible.

Below is the process I use to loop through the folders and files in Vault, to help make my point or muddy things up. It is written in VB2005.

Private Sub RecursivelySearchForFileName(ByVal Folder As VaultClientOperationsLib.VaultClientFolder, _
ByVal filename As String) ', ByRef ReturnArrayDev)
Dim SubFolder As VaultClientOperationsLib.VaultClientFolder
Dim SubFile As VaultClientOperationsLib.VaultClientFile

If Convert.IsDBNull(Folder.Files) = False Then
For Each SubFile In Folder.Files 'Loop through file list
If rbnBoth.Checked = True Then ' check File name
'********************************
If SubFile.Name.Substring(0, SubFile.Name.Length - 4).ToLower.Contains(mSearchFor) = True Then
Dim _dr1 As DataRow
_dr1 = mResultsList.NewRow
_dr1("Type") = 2 'file
_dr1("Path") = SubFile.FullPath
'_dr1("File") = SubFile.Name
mResultsList.Rows.Add(_dr1)
End If
'********************************
'look in the file??????????????????
'********************************
End If
Next
Else
Throw New Exception
End If
If Convert.IsDBNull(Folder.Files) = False Then
For Each SubFolder In Folder.Folders ' GoTo next folder
If SubFolder.FullPath.ToLower.Contains(mSearchFor) = True Then ' Add only file specified
'********************************
Dim _dr1 As DataRow
_dr1 = mResultsList.NewRow
_dr1("Type") = 1 'folder
_dr1("Path") = SubFolder.FullPath
'_dr1("File") = String.Empty
mResultsList.Rows.Add(_dr1)
'********************************
End If
RecursivelySearchForFileName(SubFolder, filename) ', ReturnArray)
Next
End If
End Sub

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Tue Jul 01, 2008 3:54 pm

I can see the appeal of what you're doing. I only have some basic recommendations.

1. Set up a server with Cruise Control.Net to constantly download the latest version of the repository to disk.
2. Use a desktop search engine (such as google desktop) to crawl that folder.

I'm sorry, but for the moment that is the best solution I can offer.
Subscribe to the Fortress/Vault blog

Post Reply