The Initialize method is called to initialize the Download command, by specifying an object store item to download and providing a name and path location for the saved file on the local machine. The client application indicates which item to download by specifying an IObjectStoreItem whose bstrVersionID parameter is either a GUID or a special version name: release, current, or reservation. The client may also identify which content element to download, by supplying the index value of the element.
The IDownloadCmd::Initialize method requires that the full pathname of the destination file must be supplied. However, if you prefer to only specify the destination directory for the file, use the IDownloadCmd2::InitializeAttachment method instead. This interface will extract the filename from the HTTP response headers attachment name.
NOTE If you would prefer to prompt the user for the filename and path location on their local machine to apply to the downloaded object store item, the client application must invoke the FileSaveAsDlg command before issuing the Download command.
void spIDownloadCmd->Initialize(_bstr_t bstrPathName, IObjectStoreItemPtr pIObjectStoreItem, long contentElementIndex);
...
// Instantiate the custom Download command component
IDownloadCmdPtr spIDownloadCmd;
hResult = spIDownloadCmd.CreateInstance(__uuidof(DownloadCmd));
if (FAILED(hResult)) {
std::cout << "Could not create the Download command component.\n";
_ASSERTE(0);
}
// Instantiate the ObjectStoreItem component
IObjectStoreItemPtr pIObjectStoreItem;
hResult = spIObjectStoreItem.CreateInstance(__uuidof(ObjectStoreItem));
if (FAILED(hResult)) {
std::cout << "Could not create the ObjectStoreItem component.\n";
_ASSERTE(0);
}
// Initialize the ObjectStoreItem component with
// the items' type, object store name, version series ID and item ID
ItemType eItemType = eItemTypeDocument;
_bstr_t bstrObjectStoreName = (_T("Alaska"));
_bstr_t bstrVersionSeriesID = (_T("{6BC064A2-2D58-4B0A-AEF2-B2F8A1100000}"));
_bstr_t bstrItemID = (_T("release"));
std::cout << "Initializing the ObjectStoreItem component..." << std::endl;
spIObjectStoreItem->Initialize(eItemType, bstrObjectStoreName, bstrVersionSeriesID, bstrItemID);
// Initialize the custom Download command component
// with the filename and path location on the local machine,
// of the downloaded object store item and optionally,
// the index value of the content element to download.
_bstr_t bstrPathName = (_T("C:\Downloaded Documents\filename.doc"));
long contentElementIndex = 0L;
std::cout << "Initializing the Download command component..." << std::endl;
spIDownloadCmd->Initialize(bstrPathName, spIObjectStoreItem, contentElementIndex);
...