Solved

Rename a file

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 108
method notes when mouse over in eclipse 5 87
fizzArray2 challenge 1 90
withoutTen challenge 14 131
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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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