How to add a path to an image name to copy an image using CopyFile , if the image name is known to us?
We have the name of the image there are two types (optional):
- type
const wchat *image_name = "001.jpg" - type
const char *image_name = "001.jpg"
There is a function:
CopyFile(L"\\image_name", L"\\0\\image_name.jpg", true); We copy the file from the root folder to the folder 0, without changing the name. It seems to be a simple case, but there is a plug.
The problem is that in quotes image_name not a variable. The question is how to add the path information to the image_name, so that it is not "001.jpg" , but "\\0\\001.jpg"
UPD
Used wcscat. But the value of p_image and pc_image does not change. Here is the code:
WIN32_FIND_DATA FindFileData; HANDLE hf; hf = FindFirstFile(L"*.jpg", &FindFileData); if (hf != INVALID_HANDLE_VALUE) { do { k = 2; //CStringW image_name = FindFileData.cFileName; //CString myConvertedString = image_name; ///*const char* namefile; //cout << "Name file"; //cin >> namefile;*/ const WCHAR* image_name = FindFileData.cFileName; const WCHAR* image_name3 = FindFileData.cFileName; _bstr_t b(image_name); const char* image_name2 = b; init_image(image_name2, k, sty); pert1 = template_1(y, x); pert2 = template_2(y, x); pert3 = template_3(y, x); /* cout << "template 1: = " << pert1 << endl; cout << "template 2: = " << pert2 << endl; cout << "template 3: = " << pert3 << endl; system("pause"); */ res = calculation_number(pert1, pert2, pert3); if (res == -1) cout << "нет распознанных цифр" << endl; if (res == 0) { cout << "Это изображение распознано как 0:" << image_name2 << endl; WCHAR *p_image = L"\\"; WCHAR *pc_image = L"\\0\\"; wchar_t* wcscat(wchar_t* p_image, const wchar_t* image_name3); wchar_t* wcscat(wchar_t* pc_image, const wchar_t* image_name3); wcout << p_image << endl; wcout << pc_image << endl; CopyFile(p_image, pc_image, true); } //std::wcout << FindFileData.cFileName << endl; } while (FindNextFile(hf, &FindFileData) != 0); FindClose(hf); system("pause"); }