×

Discussion Board

Results 1 to 4 of 4

Thread: file overwrite

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    26

    file overwrite

    Hello.
    I saw the simular code in this board about File Move.(It successed)
    Then, I did a little modification of the code like that. ( Add Overwrite Option)
    But, It failed.

    My question is
    if i wanna overwrite the file, before that, I delete 'already exists file'?
    If i delete the 'already exists file', and call move function => success!

    Just giving Overwrite Option is not enough?
    Thanks in advance.

    _LIT(KFilePathOldMove,"\\ModMobile\\abc.pl");
    _LIT(KFilePathNewMove,"\\ModMobile\\aaa.pl"); //already exists.

    RFs iFs;
    iFs.Connect();

    TBuf16<30> iFilePathOld;
    iFilePathOld.Copy(KFilePathOldMove);

    TBuf16<30> iFilePathNew;
    iFilePathNew.Copy(KFilePathNewMove);

    CFileMan* iFileMan=CFileMan::NewL(iFs);
    CleanupStack::PushL(iFileMan);

    TInt iErr=iFileMan->Move(iFilePathOld,iFilePathNew, EOverWrite);
    CleanupStack::PopAndDestroy(iFileMan);
    console->Printf(_L("\n aaa %d\n"), iErr);
    iFs.Close();
    Last edited by seera; 2006-09-28 at 06:39.

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

    Re: file overwrite

    Sorry, I do not understand what do you want to achieve. CFileMan::EOverWrite means "overwrite files with the same name". iFilePathNew should be "path indicating the directory into which the file(s) are to be moved". Try modifying your code the following way:

    Code:
    _LIT(KFileToMove,"\\ModMobile\\abc.pl");
    _LIT(KTargetPath,"\\AnotherFolder");
    
    RFs fs;
    fs.Connect();
    CleanupClosePushL(fs)
    
    CFileMan* fileMan = CFileMan::NewL(fs);
    CleanupStack::PushL(fileMan);
    
    TInt err = fileMan->Move(KFileToMove, KTargetPath, CFileMan::EOverWrite);
    CleanupStack::PopAndDestroy(2); // fileMan, fs
    console->Printf(_L("\n aaa %d\n"), err);
    Also check the following article in SDK help:
    » Developer Library » Symbian OS Guide » C++ API guide » Base » File Server Client Side » How to use sessions, files, and directories » How to move a file
    Regards,
    ivey

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Smile Re: file overwrite

    Hello Seera,

    Try:

    _LIT(KFilePathOldMove,"\\System\\abc.txt");
    _LIT(KFilePathNewMove,"\\System\\apps\\abc.txt"); //already exists.
    ...
    ...
    TInt iErr=iFileMan->Move(iFilePathOld,iFilePathNew, CFileMan::EOverWrite);
    Regards.
    Kiran.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    26

    Re: file overwrite

    Hello.

    Dear ivey.
    => sorry, English is my second language. ^^;;
    I wanna overwrite files with the same name.(same directory)
    So I use the Move(oldfilename, newfilename, EOverWrite); => iErr = Already Exist Error;
    But I use the Move(oldfilename, newfilename, CFileMan::EOverWrite);
    => It works.
    I have to use the CFileMan::EOverWrite not EOverWrite as Kiran write.
    I'm newbie for symbian program and C++. so I have no experience about that. So I mistaked ^^;;

    Dear Kiran.
    You always give me a great help!!! ^^
    Thanks you!!!!!

Similar Threads

  1. How to edit resource file (.rss) in CW 3.1
    By madsum in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 8
    Last Post: 2009-01-16, 15:00
  2. can we get the source file from jar file..
    By bb_sathya in forum Mobile Java General
    Replies: 6
    Last Post: 2005-12-28, 13:14
  3. Theme Studio incorrect sis file
    By Drakknar in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2004-09-19, 02:29
  4. How to create mbm file?
    By qt_raip in forum Symbian Tools & SDKs
    Replies: 13
    Last Post: 2004-05-12, 11:07
  5. Replies: 0
    Last Post: 2002-11-19, 08:25

Posting Permissions

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