replace 1 file with another

so im trying to replace a back up file with the main file and vice versa
im not sure if CopyFile("F:\\iofile.txt", "F:\\ARCHIVE.txt", TRUE );
is correct or if i need to open the either file first.
the rest of the 2000 lines of my code is working flawlessly, im just stuck on the syntax for this part.
thanks


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
void TESTINGFIELD()
{
     /*system("CLS");
      cout << "TESTING FIELD EMPTY";*/


	int yesNo = 0;

		system("CLS");
	cout << "you have selected to replace the main file with the back up" << endl
		  << "press 'y' to continue or any other key to cancel ";
	yesNo = getch();

	switch( yesNo )
	{
		case 'y':
		case 'Y':
			system("CLS");
			yesNo = 0;

				cout << "you have selected to continue" << endl << endl
					  << "\a#################################" << endl
					  << "##  !!       WARNING       !!  ##" << endl
					  << "#################################" << endl << endl;
				pause(1);
				cout << "\a################################" << endl
					  << "##   this can not be undone!  ##" << endl
					  << "################################" << endl << endl << endl
					  << "  are you sure you want to replace the main file with the back up ? " << endl
					  << "  press y to contine or any other key to cancel " << endl << endl;
					  yesNo = getch();

				switch( yesNo )
				{
					case 'y':
					case 'Y':
							cout << "you have now replaced the main file with the back up " << endl << endl;

							CopyFile("F:\\iofile.txt", "F:\\ARCHIVE.txt", TRUE );

						break;

					default:
							pause(1);
							cout << endl << endl << "you have cancled";
				}
			break;

		default:
			pause(1);
			cout << endl << endl << "you have cancled";
	}

	MyFile.close();
}
Topic archived. No new replies allowed.