Page 1 of 1

Read file contents

Posted: Tue Jul 01, 2008 12:36 pm
by behold
How do i read file contents in Vault? I am using Vault API 3.1.2.

Posted: Tue Jul 01, 2008 2:15 pm
by shannon
Can you clarify what you are trying to do? Are you wanting to do a get?

Read File Contents

Posted: Tue Jul 01, 2008 2:53 pm
by behold
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

Posted: Tue Jul 01, 2008 3:54 pm
by jeremy_sg
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.