How to get the content of VaultClientFile?

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

Moderator: SourceGear

Post Reply
siwachbit
Posts: 4
Joined: Mon Dec 28, 2009 8:31 am

How to get the content of VaultClientFile?

Post by siwachbit » Mon Dec 28, 2009 8:40 am

I am creating a POC to Connect to Vault Server and Get All the files.
Put All the files in Database.

I have created a function RecursivelySearchForFileName()

I am able to get the VaultClientFile object, but not get the file content.

My client and server are on different locations.

I am using C# for developing this functionality.

Please help.

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: How to get the content of VaultClientFile?

Post by Beth » Mon Dec 28, 2009 9:52 am

Can you post your code?
Beth Kieler
SourceGear Technical Support

siwachbit
Posts: 4
Joined: Mon Dec 28, 2009 8:31 am

Re: How to get the content of VaultClientFile?

Post by siwachbit » Mon Dec 28, 2009 10:24 am

I am using this function to retrieve the list of files and folder of a particular folder

public void RecursivelySearch(VaultClientFolder folder, ref ArrayList returnArray, string folderUrl, VaultConnection vConn)
{
String url = folderUrl;
if (folder.Files.Count > 0)
{
//VaultRequestGetFile[] requests = null;
//string strDownloadID = "";
foreach (VaultClientFile subfile in folder.Files)
{
VaultFileProperties vFP = subfile.GetFileProperties();
//vConn.BeginDownloadFiles(Convert.ToInt32(subfile.ID), ref requests, ref strDownloadID);
//Ned here the content of file

returnArray.Add(subfile);
}
}
if (folder.Folders.Count > 0)
{
if (baseFolderUrl == "")
baseFolderUrl = ((VaultClientOperationsLib.VaultClientTreeObject)(folder)).FullPath;

foreach (VaultClientFolder subfolder in folder.Folders)
{
string folderPath = ((VaultClientOperationsLib.VaultClientTreeObject)(subfolder)).FullPath;
string finalFolder = folderPath.Replace(baseFolderUrl, url);
//Make entry in Database for this folder
RecursivelySearch(subfolder, ref returnArray, finalFolder, vConn);
}
}
}

string baseFolderUrl = "";

shannon

Re: How to get the content of VaultClientFile?

Post by shannon » Tue Dec 29, 2009 8:28 am

What version of Vault are you using?

siwachbit
Posts: 4
Joined: Mon Dec 28, 2009 8:31 am

Re: How to get the content of VaultClientFile?

Post by siwachbit » Tue Dec 29, 2009 10:46 am

I am using Vault 5.0.2

shannon

Re: How to get the content of VaultClientFile?

Post by shannon » Tue Dec 29, 2009 11:09 am

If you are using the ServerOperations class to connect and find your files, you can just call one of the methods in GetOperations to download the file. GetOperations.ProcessCommandGetToLocationOutsideWorkingFolder, for example, would probably work for your purposes. If you aren't using ServerOperations, you can look at the code inside the methods of the GetOperations class for examples of how to use the corresponding ClientInstance methods directly.

Give that a look and let us know if you have more questions.

siwachbit
Posts: 4
Joined: Mon Dec 28, 2009 8:31 am

Re: How to get the content of VaultClientFile?

Post by siwachbit » Wed Dec 30, 2009 9:02 am

Thanks Shannon.

Is there any way to get the stream/bytestream/byte[] of the file (without storing the file into Hard Drive).
Actually, within recursive method, if I found any file, I need the file stream at that moment and I will store that content in database.

shannon

Re: How to get the content of VaultClientFile?

Post by shannon » Wed Dec 30, 2009 9:59 am

Unfortunately no, you'll need to get it to disk and then stream it yourself from there.

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: How to get the content of VaultClientFile?

Post by Beth » Mon Jan 04, 2010 4:33 pm

I'm moving this topic over to the API forum.
Beth Kieler
SourceGear Technical Support

Post Reply