Nicholas Yu Nicholas Yu - 1 year ago 171
C++ Question

how do i change a file extension on qt

I have a piece of code to download a file from server. However, due to server constraint, I can not put .exe file at server. So I rename my XXX.exe file to XXX.alt(just a random extension) and put it on server.
Now my code can download XXX.alt, but how can I change the file name from XXX.alt back to XXX.exe when in QT environment?

Answer Source

Just use rename function from 'stdio.h'.

char oldname[] ="XXX.alt";
char newname[] ="XXX.exe";
result= rename( oldname , newname );
if ( result == 0 )
  puts ( "File successfully renamed" );
  perror( "Error renaming file" );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download