×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Location
    Braunschweig
    Posts
    46

    Change default documents drive/path

    Hello,
    when i use the frameworks document support, my application document is always stored and restored from c:\myAppl.

    I tried to change the drive and path.

    To store the document somewhere else, something like this works:

    Process()->SetMainDocFileName(filename);
    Before AppUi sends "iDocument->SaveL();"

    To restore, I use in the document class:

    CFileStore* MyAppDocument::OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs)
    {
    TFileName filename;
    GetMyDocFileName(filename); // construct filename
    return CEikDocument::OpenFileL(aDoOpen, filename, aFs);
    }

    The problem is, that restore works only, if a "dummy" document is still present at the default place (C:\). It doesn't matter the content of this dummy document, but without it, Documents RestoreL(...) will not be called ?!

    What else must I do, to change the default documents drive/path/name ?


    Holler

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    Czech Republic
    Posts
    915
    Actually, I've spent few sleepless nights on this too, and found one solution that worked fine for me. Simply said, you have to override GetDefaultDocumentFileName() method inherited from CEikApplication. My code looks like this:
    ---- MyGameApp.h ------
    Code:
    class CMyGameApp : public CAknApplication
        {
        
        public:
    	virtual void GetDefaultDocumentFileName(TFileName& aFileName) const;
    etc....

    ---- MyGameApp.cpp ------
    Code:
    void CMyGameApp::GetDefaultDocumentFileName(TFileName& aFileName) const
    	{
    	aFileName.Copy(iDatFileName);
    	}
    etc...
    Where iDatFileName was obtainer this way:
    Code:
    TParsePtr parse(AppFullName());
    _LIT(KDat, ".dat");
    iDatFileName.Copy(parse.DriveAndPath());
    iDatFileName.Append(parse.Name());
    iDatFileName.Append(KDat);
    
    Process()->SetMainDocFileName(iDatFileName);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×