×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    19

    How to write to the phone directory

    Hi, I do not know what is the path to write to my N95, I tried this but it doesn't work.
    fp.Create(iFileServer,_L("c:\\data\\images\\Pictures\\temp.txt"),EFileWrite);

    so I found this code,

    TFileName path = PathInfo::PhoneMemoryRootPath();
    path.Append( PathInfo::ImagesPath() );

    However, I do not know how to add the filename to it and write it to the image directory. Please help. Thank you.

  2. #2
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: How to write to the phone directory

    Quote Originally Posted by myuuuu View Post
    Hi, I do not know what is the path to write to my N95, I tried this but it doesn't work.
    fp.Create(iFileServer,_L("c:\\data\\images\\Pictures\\temp.txt"),EFileWrite);

    so I found this code,

    TFileName path = PathInfo::PhoneMemoryRootPath();
    path.Append( PathInfo::ImagesPath() );

    However, I do not know how to add the filename to it and write it to the image directory. Please help. Thank you.
    TInt errCode = fp.Create(iFileServer,_L("c:\\data\\images\\Pictures\\temp.txt"),EFileWrite);

    and see the value of errCode.
    If it is KErrNone, do the following:
    1. Write something to the file.
    2. Close the file fp.Close();

    and now check if the file is created !

    hope this helps !
    Amit Kankani
    Nokia Developer Champion

  3. #3
    Super Contributor
    Join Date
    Jun 2006
    Location
    Moscow, Russia
    Posts
    803

    Re: How to write to the phone directory

    To append the filename:
    Code:
    TFileName path = PathInfo::PhoneMemoryRootPath();
    path.Append( PathInfo::ImagesPath() );
    _LIT(KMyFile, "temp.txt");
    path.Append(KMyFile);
    To create a file and write to it:
    Code:
    TInt err = fp.Create(iFileServer, path, EFileWrite | EFileShareAny);
    if (!err)
    {
        _LIT8(KTempString, "This is a temp string.");
        fp.Write(KTempString);
        fp.Close();
    }
    Regards,
    ivey

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    19

    Re: How to write to the phone directory

    Hi. Thank you for the help. However, the file is still not created in my phone but works on my emulator.

    This is my code:

    TFileName path = PathInfo::PhoneMemoryRootPath();
    path.Append( PathInfo::ImagesPath() );
    path.Append(_L("mytest.txt"));

    //_L("c:\\data\\images\\Pictures\\mytest.txt")
    RFs iFileServer;
    User::LeaveIfError(iFileServer.Connect());
    RFile fp;
    TInt err = fp.Open(iFileServer,path,EFileWrite);
    if(err !=KErrNone)
    fp.Create(iFileServer,path,EFileWrite);
    TInt pos=0 ;
    fp.Seek(ESeekEnd,pos);

    //_LIT8(KData,"Hi");
    //fp.Write(KData);
    fp.Close();
    iFileServer.Close();

    Do I need to print out the error myself or will it automatically generate an error code? If I need to print it out. How can I do so?

  5. #5
    Super Contributor
    Join Date
    Jun 2006
    Location
    Moscow, Russia
    Posts
    803

    Re: How to write to the phone directory

    This is how you can see the error code (the simplest way in your case):
    Code:
    TInt err = fp.Open(iFileServer,path,EFileWrite);
    if(err !=KErrNone)
        err = fp.Create(iFileServer,path,EFileWrite);
    TBuf<32> errBuf;
    errBuf.Format(_L("Error code: %d"), err);
    User::InfoPrint(errBuf);
    Regards,
    ivey

  6. #6
    Registered User
    Join Date
    Jan 2008
    Posts
    19

    Re: How to write to the phone directory

    Hi. It gave an error 0, KerrNone but the file is still not created on the phone. The, I tried to change mytest.txt to mytest.jpg. It gave an error of -1, object cannot be crated error but at least I can see the broken image icon under Gallery>>Images and Video folder from the phone. However, when I try to view it from my PC explorer, no file named ,mytest.jpg can be found. Please help. Thank you.
    Last edited by myuuuu; 2008-03-04 at 19:30.

Similar Threads

  1. directory creation
    By susha in forum Mobile Java General
    Replies: 24
    Last Post: 2007-09-10, 19:08
  2. Connecting from PC to phone via RFCOMM, OBEX
    By buzz111 in forum Symbian
    Replies: 4
    Last Post: 2007-03-01, 05:48
  3. help, write to commdb in 3rd edition working on emulator but not on phone..
    By tomasz.florczak in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2006-08-28, 12:11
  4. How to write information into a phone
    By a_n_k_u_r in forum Mobile Java General
    Replies: 2
    Last Post: 2005-04-14, 11:10
  5. Acitv Server 2.1 with Nokia Card Phone 2.0
    By lmolphy in forum WAP Servers
    Replies: 1
    Last Post: 2002-11-27, 11:19

Posting Permissions

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