×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    40

    Problem reading file from private path when program installed on memory card

    Hi,
    I have a code that reads and writes a file in private path of the program's installed directory, however the problem is that its not working when I have installed the program in memory card and it just crashes.

    Here is the code that I am using,

    ------------------------------------
    _LIT(KtxDicFileName ,"abc.txt" );

    TFileName path;
    TFileName pathWithoutDrive;
    CEikonEnv::Static()->FsSession().PrivatePath( pathWithoutDrive );

    // Extract drive letter into appDrive:

    #ifdef __WINS__
    path.Copy( _L("c:") );
    #else
    RProcess process;
    path.Copy( process.FileName().Left(2) );

    if(path.Compare(_L("c")) || path.Compare(_L("C")))
    CEikonEnv::Static()->FsSession().CreatePrivatePath(EDriveC);
    else if(path.Compare(_L("e")) || path.Compare(_L("E")))
    CEikonEnv::Static()->FsSession().CreatePrivatePath(EDriveE);
    #endif

    path.Append( pathWithoutDrive );
    path.Append( KtxDicFileName );

    TInt32 value = -1;
    RFs& fileServer = CCoeEnv::Static()->FsSession();
    User::LeaveIfError(fileServer.Connect());

    RFileReadStream readStream;

    TInt err = readStream.Open(fileServer, path, EFileRead);
    CleanupClosePushL(readStream);
    if(err == KErrNotFound)
    {
    CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
    informationNote->ExecuteLD(_L("File not found , creating"));
    value = -1;
    RFileWriteStream writeStream;
    User::LeaveIfError(writeStream.Replace(fileServer, path, EFileWrite));
    writeStream.PushL();
    writeStream.WriteInt32L(value);
    writeStream.CommitL();
    CleanupStack::PopAndDestroy(&writeStream);
    }
    else if(err == KErrNotFound)
    {
    CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
    informationNote->ExecuteLD(_L("Path not found , creating"));
    value = -1;
    RFileWriteStream writeStream;
    User::LeaveIfError(writeStream.Replace(fileServer, path, EFileWrite));
    writeStream.PushL();
    writeStream.WriteInt32L(value);
    writeStream.CommitL();
    CleanupStack::PopAndDestroy(&writeStream);
    }
    else
    {
    CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
    informationNote->ExecuteLD(_L("File found , reading"));
    readStream >> value;
    }

    CleanupStack::PopAndDestroy(&readStream);
    return value;

    ---------------------------------------------------

    I have checked the path variable by printing it on a message box and its fine like, e:\private\uid\file.ext

    Can anyone please tell me what am I am doing wrong here, the code works fine when the program is installed in phone memory.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,688

    Re: Problem reading file from private path when program installed on memory card

    Check the panic code: http://www.developer.nokia.com/Commu...ded_panic_code
    Since the e: drive is accessible in USB File Transfer mode, you could also verify if the directory gets created successfully.
    Note that starting from S60 3rd FP2, devices may also have f: drive, or even more. If you want to use this CreatePrivatePath-magic, you can use RFs::CharToDrive. Honestly said I would use a single RFs::MkDirAll (after the Append-s, since it ignores the filename-part anyway)

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    40

    Re: Problem reading file from private path when program installed on memory card

    I checked by connecting the set via USB , the directiry doesnt exist, the path that I am creating for the file is correct, I have verified that by displaying in a message box.

    I just checked that there is a problem in the code below the else if sould be like this

    else if (err == KErrPathNotFound)

    but even with this, the problem persits, how can I see the panic code??

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,688

    Re: Problem reading file from private path when program installed on memory card

    Quote Originally Posted by javed@advoss.com View Post
    but even with this, the problem persits, how can I see the panic code??
    Reading the linked article? You need the "S60 3rd Edition and later" stuff and install the ErrRd file.

Similar Threads

  1. Replies: 6
    Last Post: 2009-06-18, 09:32
  2. URGENT: Reading File from memory card problem
    By umarbasha in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2008-03-07, 10:30
  3. Replies: 3
    Last Post: 2007-06-30, 12:52
  4. Replies: 4
    Last Post: 2006-10-27, 09:45

Posting Permissions

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