Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User mayank.ty's Avatar
    Join Date
    Apr 2007
    Posts
    6

    hi all...
    can anyone tell me how to copy a file from one location to another (with the required APIs) in a console based application in Carbide.C++??




  2. #2
    Registered User david.caabeiro's Avatar
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678
    You can use the usual way: see BaflUtils::CopyFile()

  3. #3
    Regular Contributor Shilpa13's Avatar
    Join Date
    Apr 2006
    Location
    India
    Posts
    383
    Hi!

    see CFileMan class reference in sdk..

    It also can be used efficiently
    Regards,
    Shilpa Kulkarni

  4. #4
    Registered User manchb's Avatar
    Join Date
    Mar 2007
    Posts
    32
    _LIT(oldFile, "c:\\abc.txt");
    _LIT(newFile, "c:\\sample\\");

    include this header files
    #include <f32file.h>//RFs,CFileMan

    link against
    efsrv.lib

    and the code

    RFs lSess;
    User::LeaveIfError(lSess.Connect());
    CFileMan* lFlMan = CFileMan::NewL(lSess);
    User::LeaveIfError(lFlMan->Copy(oldFile,newFile));
    delete lFlMan;
    lFlMan = NULL;
    lSess.Close();

  5. #5
    Registered User mayank.ty's Avatar
    Join Date
    Apr 2007
    Posts
    6
    hi every one PushL,shilpa13 and manchb for showing interest in replying....i tried using the way manchb told me...
    actually m a newbie to symbian so it seems easier to prefer code..though also tryied my hands by doing it at my own but ...

    m giving my code here....plz take a look n tell whats wrong wid it....
    its showing error in d console saying....."failed: leave code=-1[press any key]"
    as it is defined in callConsoleTemplateL() func....

    thanks in advance
    regards,
    mayank

    here is d code....

    PHP Code:
    #include <e32debug.h>
    #include <e32base.h>
    #include <e32cons.h>
    #include <f32file.h>

    _LIT(KTxtCLHERAAPP,"CLHERA_APPLICATIONS");
    _LIT(KTxtClheraApplicationCode,"Program To Copy A File");
    _LIT(KFormatFailed,"failed: leave code=%d");
    _LIT(KTxtOK,"ok");
    _LIT(KTxtPressAnyKey," [press any key]");
    _LIT(oldFile,"c:\\oldfile.txt");
    _LIT(newFile,"c:\\newfile\\");


    // public
    LOCAL_D CConsoleBaseconsole;
    LOCAL_C void doConsoleTemplateL();

    // private
    LOCAL_C void callConsoleTemplateL();

    GLDEF_C TInt E32Main()
        {
        
    __UHEAP_MARK;
        
    CTrapCleanupcleanup=CTrapCleanup::New();
        
    TRAPD(error,callConsoleTemplateL());
        
    __ASSERT_ALWAYS(!error,User::Panic(KTxtCLHERAAPP,error));
        
    delete cleanup;
        
    __UHEAP_MARKEND;
        return 
    0;
        }

    LOCAL_C void callConsoleTemplateL()
        {
        
    console=Console::NewL(KTxtClheraApplicationCode,TSize(KConsFullScreen,KConsFullScreen));
        
    CleanupStack::PushL(console);
        
    TRAPD(error,doConsoleTemplateL(););
        if (
    error)
            
    console->Printf(KFormatFailederror);
        else
            
    console->Printf(KTxtOK);
        
    console->Printf(KTxtPressAnyKey);
        
    console->Getch();
        
    CleanupStack::PopAndDestroy();
        }

    LOCAL_C void doConsoleTemplateL()
        {
        
    #ifdef _CLHERADEBUG
        
    RDebug::Print(_L16("CLHERA_DBGMSG In DoConsoleTemplateL"));
        
    #endif
        
           // make and install the active scheduler
           
    RDebug::Print(_L16("CLHERA_DBGMSG before active scheduler"));
        
    CActiveScheduler*  scheduler = new (ELeaveCActiveScheduler;
        
    CleanupStack::PushL(scheduler); // push to clean-up stack
        
    CActiveScheduler::Install(scheduler); // install as active scheduler
        
        
    TUint ch;
        while(
    1)
               {
        
    RFs lSess;
        
    User::LeaveIfError(lSess.Connect());
        
    CFileManlFlMan CFileMan::NewL(lSess);
        
    User::LeaveIfError(lFlMan->Copy(oldFile,newFile));
        
    delete lFlMan;
        
    lFlMan NULL;
        
    lSess.Close();        
        
               
    ch console->Getch();
            
    RDebug::Printf("CLHERA_DBGMSG getch: %d",ch);
            
        }
            
        
    CleanupStack::PopAndDestroy(); // scheduler   
      


  6. #6
    Registered User david.caabeiro's Avatar
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678
    -1 is KErrNotFound, which seems to be triggered by the copy. Does oldFile exist? Also, you can remove the active scheduler related calls, as it's not needed in this case so far.

  7. #7
    Nokia Developer Champion hotcheese's Avatar
    Join Date
    Jul 2004
    Posts
    2,015
    And don't forget C:\ in the Symbian file system doesn't mean the file should be in C:\ on your PC if that is where you have placed it.

  8. #8
    Registered User mayank.ty's Avatar
    Join Date
    Apr 2007
    Posts
    6
    thanx 4 replying PushL and hotcheese....
    i removed that active scheduler calls....and now atleast that error is removed.
    but still nothing is getting copied....
    i tried all d options with both "oldfile" and "newfile" existing and noexisting as well.


    desperately waiting for a reply...
    thanx in advance..

  9. #9
    Nokia Developer Champion kiran10182's Avatar
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,240
    Hi,
    Quote Originally Posted by mayank.ty
    ...
    desperately waiting for a reply...
    thanx in advance..
    As Hotcheese and PushL mentioned, would you please clarify where do these File and Folder exist on your PC:
    _LIT(oldFile,"c:\\oldfile.txt");
    _LIT(newFile,"c:\\newfile\\");

    You can list down complete path here.

    Kiran.

  10. #10
    Super Contributor Priju Jacob Paul's Avatar
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156
    Well, manchb's code works perfectly for me.
    As all other champions have mentioned please be free to modify the path from c:\\oldfile.txt to c:\\system\\oldfile.txt and place the oldfile.txt in
    C:\Symbian\8.0a\S60_2nd_FP2_CW\Epoc32\winscw\c\system and also mention the new files path to c:\\system\\newfile.txt

    Priju

  11. #11
    Registered User mayank.ty's Avatar
    Join Date
    Apr 2007
    Posts
    6

    hi priju jacob and kiran...

    thanx a lot to u ppl...u were life saver for me this time...
    it worked....phewwww... )
    hope i shall get to u ppls level of coding soon...
    thanx again every one for taking interest...

    Regards,
    Mayank


Similar Threads

  1. Replies: 6
    Last Post: 2007-04-18, 11:44
  2. how to install an sisx application by including the file in image through iby file
    By arun_stmicro in forum Mobile Web Site Development
    Replies: 3
    Last Post: 2006-10-27, 08:52
  3. Read resource file from a console application
    By LailaVarghese in forum Mobile Java General
    Replies: 3
    Last Post: 2005-10-30, 14:57
  4. Replies: 1
    Last Post: 2005-05-26, 14:22
  5. How to Access 9210 Dbms file from my desktop application?
    By Nokia_Archive in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2002-06-03, 03:46

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