![](../../../Home/Icons/Home.gif)
![](../icons/UpBook.gif)
![](../icons/BookContext.gif)
![](../../../Home/Icons/Search.gif)
![](../../../Home/Icons/Help.gif)
![](../../icons/button_contents.gif)
![](../../icons/button_previous.gif)
Retrieving an
archived object
To retrieve an object from an archive, use the template class TArchiveEnvelope. You must know:
- The name of the object
- The name of the archive in which it is stored
The class TArchive gives you access to an archive for retrieving individual archived objects.
To retrieve an object from an archive:
- Open the archive for accessing the contents by instantiating TArchive with the directory and library name of the archive.
By default, the archive is opened for read and write access. You should open the archive for read-only access when possible so that other users can still access the archive while you are copying an object. You specify read-only access in the TArchive constructor.
- Create a TArchiveEnvelope instance to wrap the object you want to retrieve.
If you do not specify a locale, the current locale is used. The constructor throws an exception if the specified archive does not exist.
- Retrieve the object by calling TArchiveEnvelope::CopyObject, specifying the name of the object.
For example, this code shows how to retrieve the object named Image,
added in the previous example, from the archive MyLibrary
.
// Open the archive.
TDeleterFor<TArchive> archive = new TArchive( directory, TStandardText("MyArchive"),
TArchive::kOpen, TArchive::kReadOnly );
// Create a wrapper for a TImage instance.
TArchiveEnvelope<TImage> envelope( archive );
// Get a copy of the TImage instance.
TStandardText objectID( "Image" );
TDeleterFor<TImage> retrievedImage = envelope.CopyObject( objectID );
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.
Generated with WebMaker