Solved

Rename a file

Posted on 2007-12-03
4
334 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 61
Turn a spreadsheet into a vba executable. 2 87
Hibernate methods 2 72
scoreUp challenge 14 63
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.

821 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