Programming tutorials online .NET, Java, C++, Visual Basic, and More
 

Home
.NET Tutorials
General Programming Tutorials
Community/Forums
Site Extras

 

C/C++ Forum
 

Open forum for posting questions or comments regarding C/C++.


POST REPLY
Posted By: elizabethz   5/10/2006 4:54:00 AM
 
how to rename a folder by appending a phrase to the existing foldername?

hi,
here i ve got a program, which searches out the information (char verdict) from the content of a known file ( foldername\\file).
now i wish to rename the folder by replacing foldername with foldername_verdict.
so i wrote a short code as below.
however, it seems that rename() cannot work correctly.
who can help me correct my code?thank you so much.

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include


#define MAX_LEN 200
#define STR_LEN 400

using namespace std;

FILE *openfile;

void main ()
{
char testCase[MAX_LEN] = {0};
char textTemp[10][STR_LEN] = {0};
char verdict[10] = {0};
char new_testCase[MAX_LEN] = {0};
char testName[MAX_LEN] = {0};
strcpy ( testCase, "C:\\TEMP\\WR03.0\\Multi_Call.0" );
//"C:\\TEMP\\WR03.0\\Multi_Call.0"is the original folder name.
strcpy ( new_testCase, testCase );
strcat ( testCase, "\\TestCaseReport.tcr" );
//now the file name is:"C:\\TEMP\\WR03.0\\Multi_Call.0\\TestCaseReport.tcr"
openfile = fopen ( testCase, "r" );
// read the file to get the verdict of the test case
if ( openfile != NULL )
{
cout for ( int i = 0; i {
fgets ( textTemp[i], 200, openfile );
cout
if ( strstr( textTemp[i], "TCR_Verdict value" ) != NULL )
{
if ( 1 != sscanf ( textTemp[i], "%*[^']'%[^']", verdict ) )
cout else
{

cout strcat ( new_testCase, "_" );
cout strcat ( new_testCase, verdict );
cout //now, i wanna change the folder name to "C:\\TEMP\\WR03.0\\Multi_Call.0_verdict"
rename ( testCase, new_testCase );

}
}
}
}
fclose ( openfile );
}
moreover, if i wish to copy this folder to another directory, ie. D:\TEMP, what should i do?






 
Sign In
Email
Password
  Forgot my password

Search

Featured Book

Introducing Microsoft .Net, Third Edition ($19.79)
Introducing Microsoft .Net, Third Edition


Featured Software

Microsoft Visual Studio Standard 2005 ($249.99)
Microsoft Visual Studio Standard 2005





 
© 2022 Ammastore.org
All Rights Reserved
COMPUTER SCIENCE HOMEWORK | Privacy/Disclaimer