Gs.
Gs.

Reputation: 592

How can i change filename in c++

I want to change Filename. Program is MVC of c++.

I searched and found some method. Then, I have tried changing with rename method which in cstdio lib.

I wrote just this one Line.

std::rename("C:\\CNV\\Image\\GETDATA\\9KA13103.SLDPRT", "C:\\CNV\\Image\\GETDATA\\9KA13103-02A.SLDPRT");

But, that is return -1.

also, I had tried to use other library which filesystem::tr2::sys::rename But, That was fail too.

All example source which i found in internet to use cstdio::std::rename. Wrote just filename in rename method like

std::rename("abc.txt", "123.txt");

But i thought That is weird what write just filename not included path. But now, I expect that i have misunderstood about using std::rename.

Please can you tell me How can i do this. Thank you.

Upvotes: 2

Views: 1508

Answers (1)

Gs.
Gs.

Reputation: 592

paddy // You are right.

The reason was file opened.

I perceived that i had tried to change file name while file opened. So i Edit that try changing name after closing SolidWorks Process.

Thank you

Upvotes: 1

Related Questions