3

I tried renaming a fie with Follwoing Syntax:

int iRenameXML,iRenameXMLErr;
iRenameXML = rename("D:\Debug\CurrentServers.xml",
                             "D:\Debug\CurrentServersssss.xml");
iRenameXMLErr = GetLastError();

But this Get me GLE 2 ,ERROR_FILE_NOT_FOUND.

Is there any other way I can change tha name of a file at other location.

I do not think chdir will be a good idea.

2 Answers 2

4

You need do double backslash the \

int iRenameXML,iRenameXMLErr;
iRenameXML = rename("D:\\Debug\\CurrentServers.xml",
                             "D:\\Debug\\CurrentServersssss.xml");
iRenameXMLErr = GetLastError();
2
  • Thanks . Forgetting escape sequence :) I don't want to do this agn
    – Simsons
    Commented Dec 6, 2010 at 10:46
  • @Subhen You're welcome. I forget too when going back to C++ from C#, in C# I can do @"D:\Debug\CurrentServers.xml" and not worry about escape sequences! Commented Dec 6, 2010 at 10:56
2

See "[15.16] Why can't I open a file in a different directory such as "..\test.dat"?" in the C++ FAQ Lite.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.