Copying Files

Hi there,

today I've got a new problem and I can't see why it's not working.

I've written my program and now want to write a little "installation-programme".

Looks like:
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
  void main()
{
	//Create directories
	printf("----------------------------------------------------------------\n");
	printf("** Creating directories **");
	LPCTSTR path = L"C:\\DataLogger\\Input";
	SHCreateDirectoryEx(NULL, path, NULL);
	path = L"C:\\DataLogger\\Output";
	SHCreateDirectoryEx(NULL, path, NULL);
	Sleep(1000);
	printf("  -> ");
	coloured();
	Sleep(500);

	//Copy Files
	printf("----------------------------------------------------------------\n");
	printf("** Copying files to C:/DataLogger/ **\n\n");
	Sleep(500);
	
	printf("-> Datalogger.exe");
	Sleep(500); printf("  -> "); coloured(); Sleep(500);
	CopyFile(TEXT("../../bin/Release/bin.exe"), TEXT("C:/DataLogger/Datalogger.exe"), false);
	
	printf("-> CH1_Weight.txt");
	CopyFile(TEXT("../../bin/bin/CH1_Weight.txt"), TEXT("C:/DataLogger/Input/CH1_Weight.txt"), false);
	Sleep(500); printf("  -> "); coloured(); Sleep(500);
	
	printf("-> CH1_Temperature.txt");
	CopyFile(TEXT("../../bin/bin/CH1_Temperature.txt"), TEXT("C:/DataLogger/Input/CH1_Temperature.txt"), false);
	Sleep(500); printf("  -> "); coloured(); Sleep(500);

	printf("-> CH1_Speed.txt");
	CopyFile(TEXT("../../bin/bin/CH1_Speed.txt"), TEXT("C:/DataLogger/Input/CH1_Speed.txt"), false);
	Sleep(500); printf("  -> "); coloured(); Sleep(500);

	printf("----------------------------------------------------------------\n");
	printf("** Programme successfully installed. Press any key to exit. **\n");
	_getch();
}


When I run the programme on my harddisk everything works fine.
But if I now copy the whole project foder onto a usb-stick it doesn't copy anymore.

install.exe -> \Datalogger\Install\Release\
all other files -> \Datalogger\bin\Release\ or \Datalogger\bin\bin

I just copy the whole "Datalogger"-folder onto USB.

Could anybody help me please?

Cheers.
Last edited on
Oh found it out myself.

the correct path for CopyFile() is "../Datalogger/bin/bin/"
Teddy Bear!

Another effective technique is to explain your code to someone else. This will often cause you to explain the bug to yourself. Sometimes it takes no more than a few sentences, followed by an embarrassed “Never mind, I see what’s wrong. Sorry to bother you.” This works remarkably well; you can even use non-programmers as listeners. One university computer center kept a teddy bear near the help desk. Students with mysterious bugs were required to explain them to the bear before they could speak to a human counselor.

Brian Kernighan and Rob Pike, in The Practice of Programming
Another effective technique is to explain your code to someone else.
Or to rubber duck.
https://en.wikipedia.org/wiki/Rubber_duck_debugging
http://www.rubberduckdebugging.com/
Last edited on
Topic archived. No new replies allowed.