Answer the question
In order to leave comments, you need to log in
How to copy an image using CopyFile if we know the name of the image?
Hello.
How to copy an image using CopyFile if we know the name of the image?
We have an image name, there are two types (to choose from):
1. type const wchat *image_name = "001.jpg"
2. type const char *image_name2 = "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 folder 0, without changing the name.
It seems like a simple case, but there was a gag.
UPD:
Used wcscat. But the value p_image
does pc_image
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");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question