I'm creating a windows service that copies a file to an external thumb drive using CopyFileW
.
Everything works as expected, but the problem is that windows copies the file to thumb drive and it shows as a 'File' type and can be neither deleted, copied, moved nor renamed.
I tried GetLastError
and there was no errors, i.e CopyFile
returned true
.
It does work if the destination file is on the C
drive.
Here's the code responsible for copying the file :
LPWSTR filename = PathFindFileNameW(file.first.c_str());
LPWSTR mediaFilePath = new WCHAR[1000];
wcscpy_s(mediaFilePath, 255, lpdbv->dbcc_name);
wcscat_s(mediaFilePath, 255, L"\\");
wcscat_s(mediaFilePath, 255, filename);
bool copied = CopyFileW(file.first.c_str(), mediaFilePath, false);
if (!copied) {
logToFile(L"Couldn't copy file, error " + GetLastError());
}