I am trying to find files with specific name and deleting them in c++ as this code works fine if i give direct desktop path to it L"path//" but as path of desktop is different due to different user and system so i what i am doing at the top is to get desktop path in string variable and assigning it rather than direct path.
string desk=getenv("DESKTOP");
WIN32_FIND_DATAW fd;
HANDLE hFind = FindFirstFileW(desk, &fd);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
DeleteFileW((wstring(desk) + fd.cFileName).c_str());
} while (FindNextFileW(hFind, &fd));
FindClose(hFind);
}
I am getting the following error
Error 4 error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'std::string' to 'LPCWSTR'
I have already tried using wstring and wchar but it gives error again. Can anyone please help me to sortout this issue. looking for correction in code