Stò cercando di scrivere un'applicazione che salvi in una cartella di nome Prova le immagini in ingresso tramite bluetooth. Ecco qui il codice che ho scritto:
if (*(static_cast<TMsvId*>(aArg2)) == KMsvGlobalInBoxIndexEntryId) //id of the inbox folder
{
CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
if( iNewMessageId == entries->At(0) )
{
const TMsvId id = entries->At(0);
TInt uid = id;
CMsvEntry* btEntry = iSession->GetEntryL(id);
CleanupStack::PushL(btEntry);
CMsvEntrySelection* btChildren = btEntry->ChildrenL();
CleanupStack::PushL(btChildren);
TInt childCount = btChildren->Count();
if (childCount>0)
{
for(TInt i=0; i<childCount; i++)
{
TMsvId btAtt = (*btChildren)[i];
btEntry->SetEntryL(btAtt);
if (btEntry->HasStoreL())
{
CMsvStore* store = btEntry->ReadStoreL();
CleanupStack::PushL(store);
MMsvAttachmentManager& attMngr = store->AttachmentManagerL();
TInt attcount = attMngr.AttachmentCount();
for(TInt j=0; j<attcount; j++)
{
CMsvAttachment* attachment = attMngr.GetAttachmentInfoL(j);
//TInt size = attachment->Size(); //aggiunta io per vedere la dimensione dell'attachment
TPtrC ptr = attachment->AttachmentName();
TPtrC8 mime = attachment->MimeType();
if(mimeBufgif.CompareF(attachment->MimeType())== 0)
{
//iEventKeeperContainer->WriteOnScreen("NAME...");
iEventKeeperContainer->WriteOnScreen(ptr);
//iEventKeeperContainer->WriteOnScreen(attachment->Size());
//iEventKeeperContainer->WriteOnScreen("MIME TYPE");
//iEventKeeperContainer->WriteOnScreen(mime);
//iEventKeeperContainer->WriteOnScreen("NAME LENGHT %d", ptr.Lenght());
/*
* SALVATAGGIO DEL FILE VERO E PROPRIO
*
*/
RFile file = attMngr.GetAttachmentFileL(j);
TInt size;
file.Size(size);
TFileName copyfileName;
copyfileName.Copy( _L("C:\\Prova\\"));
copyfileName.Append(ptr);
RFile toFile;
RFs iSession;
iSession.Connect();
TInt delerr = iSession.Delete(copyfileName);
//if(delerr == KErrNotFound || delerr == KErrNone)
toFile.Create(iSession,copyfileName,EFileWrite);
HBufC8* bufferDes = NULL;
bufferDes = HBufC8::NewLC(size);
TPtr8 BDPointer(bufferDes->Des());
User::LeaveIfError(file.Read(BDPointer, size));
User::LeaveIfError(toFile.Write(BDPointer,size));
CleanupStack::PopAndDestroy(bufferDes);
toFile.Flush();
toFile.Close();
//iFilePaths->AppendL(copyfileName);
//else
//{
//}
file.Flush();
file.Close();
iSession.Close();
/*
* FINE SALVATAGGIO FILE
* */
}
}
CleanupStack::PopAndDestroy(store);
} //if (btEntry)
} //for
} // if (childCount)
CleanupStack::PopAndDestroy(btChildren);
CleanupStack::PopAndDestroy(btEntry);
}
}Provando il codice con l'emulatore vedo che le immagini vengono copiate nella cartella prova, il problema sorge quando tramite l'emulatore provo ad accedere nella cartella Inbox e cancellare il messaggio di cui ho salvato l'immagine: non mi permette di cancellarlo e sul display mi appare il messaggio d'errore: ALREADY IN USE (-14).
Qualcuno saprebbe aiutarmi?
grazie a tutti

Aiuto












Pubblicità