This page was last modified 09:20, 1 July 2008.
CS001053 - Copying content to predefined directories with CDocumentHandler
From Forum Nokia Wiki
| ID | CS001053 | Creation date | July 1, 2008 |
| Platform | S60 3rd Edition, FP1 | Tested on devices | Nokia N95 8GB |
| Category | Symbian C++ | Subcategory | Files/Data |
| Keywords (APIs, classes, methods, functions): CDocumentHandler, TDataType, TFileName, CDocumentHandler::CopyL(), CDocumentHandler::GetPath() |
Overview
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, KEntryAttNormal)); if (err || ret) { // TODO: Error handling } // Get and display the destination path TFileName path; iDocHandler->GetPath(path); CAknInformationNote* note = new (ELeave)CAknInformationNote(ETrue); note->ExecuteLD(path);
Postconditions
Source file C:\Data\Others\picture.jpg is copied into the Gallery as destination.jpg.
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem in writing data into gallery | Basu | Mobile Java Networking & Messaging & Security | 8 | 2007-05-30 22:19 |
| 查找文件遇到的问题? | csh_cao | Symbian | 3 | 2005-04-13 11:04 |
| [announce] Ensymble v0.26 | jethro.fn | Python | 7 | 2008-03-15 16:35 |
| N95 Exclude Directories from Music Player. | staripper | General Discussion | 2 | 2008-02-25 08:14 |
| converting TDesc8& to HBuf | manishraj | General Symbian C++ | 11 | 2007-09-18 09:22 |

