×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    150

    How to create a file and store the contents of the page i connect to on internet

    Hi all,

    I am Creating a file in HttpClientExample DoHTTPGetL()method

    as
    _LIT(KXMLFilePath,"C:\\Temp\\Example.xml");
    RFs iFssession;
    RFile iRFileObj;
    iFssession.Connect();
    TInt err=iRFileObj.Create(iFsSession,KXMLFilePath,EFileWrite|EFileRead);

    but it returns err value as -12.

    and in the MHFRunL()

    i do as

    case THTTPEvent::EGotResponseBodyData:
    {
    // Part (or all) of response's body data received. Use
    // aTransaction.Response().Body()->GetNextDataPart() to get the actual
    // body data.

    // Get the body data supplier
    MHTTPDataSupplier* body = aTransaction.Response().Body();
    TPtrC8 dataChunk;
    TInt aPos=0;
    iRFileObj.Seek(ESeekCurrent, aPos);
    iRFileObj.Write(dataChunk); //save the file being downloaded
    HBufC* buf = HBufC::NewLC(dataChunk.Length());
    buf->Des().Copy(dataChunk);
    HBufC* iResponseBuffer;
    if (!iResponseBuffer)
    {
    iResponseBuffer = buf->AllocL();
    }

    else
    {
    iResponseBuffer = iResponseBuffer->ReAllocL(iResponseBuffer->Length()+buf->Length());
    iResponseBuffer->Des().Copy(*buf);
    }
    // Release buf
    CleanupStack::PopAndDestroy(buf);



    So first the file is not created at all.
    can u plz tell where i m doing the error?

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

    Re: How to create a file and store the contents of the page i connect to on internet

    Almost there: http://wiki.forum.nokia.com/index.php/Error_codes
    "iFssession.MkDir(KXMLFilePath);" may help.

  3. #3
    Regular Contributor
    Join Date
    Aug 2005
    Location
    India
    Posts
    399

    Re: How to create a file and store the contents of the page i connect to on internet

    -12 is KErrPathNotFound. So the path is not valid. Create the complete path first with RFs 's MkDir

  4. #4
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    150

    Re: How to create a file and store the contents of the page i connect to on internet

    ok.Thanks Wiz and aficiando.

  5. #5
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    150

    Red face Re: How to create a file and store the contents of the page i connect to on internet

    Yes it worked.but when i am opening the file it says declaration has an invalid name.Error processing resource.

    I have done the file creation as

    _LIT(KXMLFilePath,"C:\\Temp\\example.xml");

    iFsSession.Connect();
    iFsSession.MkDirAll(KXMLFilePath);

    TInt err=iRFileObj.Create(iFsSession,KXMLFilePath,EFileWrite);
    How to resolve it?

  6. #6
    Super Contributor
    Join Date
    Sep 2007
    Posts
    1,005

    Re: How to create a file and store the contents of the page i connect to on internet

    Quote Originally Posted by abhinay.krs View Post
    Yes it worked.but when i am opening the file it says declaration has an invalid name.Error processing resource.

    I have done the file creation as

    _LIT(KXMLFilePath,"C:\\Temp\\example.xml");

    iFsSession.Connect();
    iFsSession.MkDirAll(KXMLFilePath);

    TInt err=iRFileObj.Create(iFsSession,KXMLFilePath,EFileWrite);
    How to resolve it?
    you can do it
    iFsSession.MkDirAll(_L("C:\\Temp\\"));

Similar Threads

  1. Trusted Application
    By damien_a in forum Mobile Java General
    Replies: 11
    Last Post: 2012-02-17, 20:49
  2. Regarding BMCONV
    By sanah007 in forum Symbian
    Replies: 2
    Last Post: 2009-05-26, 12:47
  3. Replies: 1
    Last Post: 2005-05-26, 14:22
  4. Replies: 0
    Last Post: 2002-06-10, 12:24

Posting Permissions

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