×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Aug 2010
    Location
    Gurgaon, Haryana
    Posts
    62

    Arrow System error -21 when creating a database file in private folder

    Hi All,
    I am creating a database file in private folder using S60 3rdEd. MR emulator. It gives System Error -21 in the file creation statement.
    My code:
    Code:
    const TInt KPathNameLength = 200;
    TBuf< KPathNameLength > pathWithoutDrive;
    TBuf< KPathNameLength > driveAndPath;
    TBuf< 2 > appDrive;
    _LIT(KHistoryDbFileName,"history");
    
    TFileName DBFileName;
    CCoeEnv::Static()->FsSession().PrivatePath( pathWithoutDrive );
    appDrive.Copy(CEikonEnv::Static()->EikAppUi()->Application()->AppFullName().Left(2));
    DBFileName.Copy(appDrive);
    DBFileName.Append(pathWithoutDrive);
    DBFileName.Append(KHistoryDbFileName);
    
    		if(BaflUtils::FileExists(iFsSession, DBFileName))
    			{
    			User::LeaveIfError(iItemsDatabase.Open(iFsSession,
    					DBFileName));
    			}
    		else
    			{	
    			User::LeaveIfError(iItemsDatabase.Create(iFsSession,
    					DBFileName)); //This line gives System error -21
    			CreateTableL(iItemsDatabase);
    			}
    This problem is coming on emulator.
    What am I missing?
    Please help

    Thanks,
    Rituraj

  2. #2
    Regular Contributor
    Join Date
    May 2010
    Posts
    362

    Re: System error -21 when creating a database file in private folder

    First step would be to verify that the path exists. You can do that in emulator by your self, but best option is to do it programmatically:

    Code:
    BaflUtils::EnsurePathExistsL(iFsSession, DBFileName);

  3. #3
    Registered User
    Join Date
    Aug 2010
    Location
    Gurgaon, Haryana
    Posts
    62

    Re: System error -21 when creating a database file in private folder

    Hi Teemup,
    This code is working well on device. But on emulator the drive is Z: which is ROM. So we cannot access this drive and its memory. But how to write my database file in private folder in emulator?

  4. #4
    Regular Contributor
    Join Date
    May 2010
    Posts
    362

    Re: System error -21 when creating a database file in private folder

    You should make a #ifdef to check if you are running on emulator, and in that case you would always use C: drive.

    Code:
    	#ifdef __WINS__   // In emulator, always use C drive
                    _LIT(KCDrive, "C:");
    		DBFileName.Append(0,KCDrive);
    	#else // In device use the correct drive
    	   DBFileName.Append(appDrive);
    	#endif

  5. #5
    Registered User
    Join Date
    Aug 2010
    Location
    Gurgaon, Haryana
    Posts
    62

    Re: System error -21 when creating a database file in private folder

    Thanks a lot Teemup

Similar Threads

  1. Replies: 2
    Last Post: 2011-06-29, 08:07
  2. Creating Folder in Private Path
    By gailu in forum Symbian
    Replies: 9
    Last Post: 2008-08-19, 21:35
  3. Replies: 3
    Last Post: 2007-09-20, 16:48
  4. Load Flash file from private folder - error -25502
    By heuven in forum Symbian Networking & Messaging (Closed)
    Replies: 6
    Last Post: 2007-08-22, 14:09
  5. Access denied for database in private folder
    By ronin101 in forum Symbian
    Replies: 2
    Last Post: 2007-03-30, 13:03

Posting Permissions

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