Discussion Board

Results 1 to 4 of 4
  1. #1
    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 wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    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
    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 wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    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. KErrCorrupt occur while reading file from memory card
    By sksarun.k in forum Symbian C++
    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. Problem in reading messages from Memory card and phone memory
    By bonrix in forum Web Technologies and Multimedia Content- Web 技术和多媒体内容
    Replies: 0
    Last Post: 2007-07-23, 14:33
  4. Replies: 3
    Last Post: 2007-06-30, 12:52
  5. problem with 'file reading' when installed on memory card
    By shahzadamin in forum Symbian C++
    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
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved