Moving a file to a created directory

closed account (iGLbpfjN)
Well, in my code I create a directory and a file in the place where the .exe file is. I found a function in this forum that returns the path location of the .exe file (because I can run the program in different places). Then, I want to move the file to inside the created directory, but I can't use the return value of current_working_directory() in MoveFile(). This is what I got so far...

***********PROBLEM SOLVED!!!*************
The solution was so simple... Just use current_working_directory().c_str() =X

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
string current_working_directory()
{
        string add = "\\Private\\Password.dat";
// This is right? I want to put the file inside the Private folder
	char working_directory[MAX_PATH + 1];
	GetCurrentDirectoryA(sizeof(working_directory), working_directory);
	return working_directory + add;
}

if (checkFile("Password.dat") == false)
// If the Password.dat doesn't exist, then the user must create a password =P
	{
		ofstream passwordSave;

		passwordSave.open("Password.dat");

		cout << "Create a password: ";
		cin >> password;

		passwordSave << password;

		passwordSave.close();

		MoveFile("Password.dat", current_working_directory());
// Here is where I want to move the file, but it gives me
// No suitable conversion function from std::string to LPCSTR exists

		return 0;
	}
Last edited on
Topic archived. No new replies allowed.