user3036674
user3036674

Reputation: 163

rename() not working in C under Win XP

rename("E348.def","E348__.hex"); works, but renaming does not work on files higher up on the directory tree.

Works- rename("/tmp/test", "/tmp/test2");

Doesn't work- rename("/hex/E348.def","hex/E348__.hex" );

Program path: /hex/.
The hex directory DOES exist and so do the files.
I'm running WIN XP.

Upvotes: 0

Views: 142

Answers (2)

AShelly
AShelly

Reputation: 35520

You are doing a move, not a rename:

rename("/hex/E348.def","hex/E348__.hex" );
        ^              ^
 leading slash        no slash

Upvotes: 3

Sergej Christoforov
Sergej Christoforov

Reputation: 1606

"/hex/E348.def" is an absolute path. If your path is "...../here is my program/hex/", you should use "hex/E348.def".

Upvotes: 1

Related Questions