samedi 18 octobre 2014

Using CopyFile() WinAPI, file isn't getting copied. C++


Vote count:

0




I am using 2 different APIs here in C++, one is for getting user's temp folder and other to copy file to that folder. However the 2nd API, CopyFile isn't working. Can anyone throw some light and tell me why?


My C++ Code:



#include <iostream>
#include <windows.h>
#include <string>

using namespace std;
int main () {
system("cls");
SetConsoleTitle("File Copy");
DWORD temp = 0;
TCHAR tempfile [MAX_PATH];
TCHAR temppath [MAX_PATH];

/* Get user's temp folder. */
temp = GetTempPath(MAX_PATH, temppath);
string path2 = "sysperf\\";

/* Append the final directory. */
string f_path = temppath + path2;

/* Convert to char from string since API doesn't initialize because of string variable. */
const char *fpath = f_path.c_str();
cout << fpath;

/* Copy file to the temp path. */
CopyFile("D:\\test.txt", fpath, FALSE);
}


So what wrong am I doing here? Thanks in advance. :)



asked 27 secs ago

blah

33






Using CopyFile() WinAPI, file isn't getting copied. C++

Aucun commentaire:

Enregistrer un commentaire