Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename File V6 C++

Status
Not open for further replies.

nbgoku

Programmer
May 25, 2004
108
US
how to rename file C:\1.txt to c:\2.txt

i would like the rename to occur after the button is clicked on:

void Crename_fileDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here

}

do i gotta use CFile::Rename somehow? if yes, could someone plz show how
 
Use the "MoveFile" function:

Code:
MoveFile ("C:\\1.txt", "C:\\2.txt");
 
Or ANSI/ISO Standard library function:
Code:
int rename( const char *oldname, const char *newname );
What's a problem?..
 
actually if someon can, can they plz tell me how i can add "_" underscores wherever there are spaces in my file name, that is why iwas trying to get the array thing working, wanted to see how it worked, the main point is to replace all spaces with underscores so something like

abc 31.jpg becomes abc_31.jpg
 
Assuming you are using a CString, just use the Replace function.
Code:
CString filename = "abc 31.jpg";
filename.Replace(' ', '_');
// filename == abc_31.jpg
 
SWEET MAN! HAHA WORKS NICELY! :) THANKs!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top