Solved

Rename a file

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now