Copying content to predefined directories with CDocumentHandler

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia N95 8GB
Platform(s): S60 3rd Edition, FP1
Keywords: CDocumentHandler, TDataType, TFileName, CDocumentHandler::CopyL(), CDocumentHandler::GetPath()
Created: tapla (06 Jun 2008)
Last edited: hamishwillee (13 Jun 2012)



Certain file types are meant to be in certain directories. The Document Handler API is able to find the correct place for known file types, such as images or sound files. This snippet demonstrates how to copy content to predefined directories with CDocumentHandler.

This snippet can be self-signed.

MMP file

The following libraries are required:

LIBRARY apmime.lib    // TDataType
LIBRARY commonui.lib // CDocumentHandler

Header file

#include <DocumentHandler.h>
private:  // Data
CDocumentHandler* iDocHandler;

Source file

#include <DocumentHandler.h>
iDocHandler = CDocumentHandler::NewL(CEikonEnv::Static()->Process());
// Source file.
_LIT(KSrcFile, "C:\\Data\\Others\\picture.jpg");
// Destination file. File extension is obtained from the source file.
_LIT(KDestFile, "destination");
TDataType nullType; // Explicit MIME type not set
TInt ret = KErrNone;
// Copy the source to the destination. The Document Handler API recognizes that
// the file is an image and copies it to the Gallery (C:\Data\Images directory
// in S60 3rd Edition). The function call also displays a notification to the
// user after copying is done.
TRAPD(err, ret = iDocHandler->CopyL(KSrcFile, KDestFile, nullType,
if (err || ret)
// TODO: Error handling
// Get and display the destination path
TFileName path;
CAknInformationNote* note = new (ELeave)CAknInformationNote(ETrue);


Source file C:\Data\Others\picture.jpg is copied into the Gallery as destination.jpg.

This page was last modified on 13 June 2012, at 08:52.
44 page views in the last 30 days.