Solved

Rename a file

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

896 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

16 Experts available now in Live!

Get 1:1 Help Now