Solved

Rename a file

Posted on 2007-12-03
4
337 Views
Last Modified: 2013-11-20
Hi Experts,
I want to rename my file.When I pass the contant string it is working but when i pass the string using variable it popup a messagebox :
 "can't rename file : select only one file to rename , or use MS-DOS wildcard (e.g *.txt) to raname a group of files with similar names"

I writeen the code like this plz check (projecy is unicode enabled)

CString szFilePath,szFileName,szFileExt,szNewFilePath;
LPCTSTR lpSourceFileName;
lpSourceFileName=szSourceFilePath;

SHFILEOPSTRUCT sfo;
ZeroMemory ( &sfo, sizeof (SHFILEOPSTRUCT));
sfo.wFunc = FO_MOVE ;
CString szFN=_T("f:\\pp.txt");
sfo.pFrom =szFN;//lpSourceFileName;//+_T("\0\0");
sfo.pTo = _T("f:\\pp3.txt\0");
0
Comment
Question by:tariq6000
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 125 total points
ID: 20396358
Have you tried

MoveFile(_T("f:\\pp.txt"),_T("f:\\pp3.txt"));

?
0
 
LVL 1

Assisted Solution

by:umamaheswari_K
umamaheswari_K earned 125 total points
ID: 20784356
use the following one

FO_RENAME
    Rename the file specified in pFrom. You cannot use this flag to rename multiple files with a single function call

refer this URL:
http://www.programmerworld.net/sourcecode/bulkrename.php


http://www.cleansofts.com/softdownload/103/34951/Bulk_Rename_Utility.html
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21026320
Forced accept.

Computer101
EE Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question