Windows API's CreateFile with CFile gives invalid path error if used drives created with SUBST
Dada Khalandhar Gooty
0
Reputation points
A drive is created for a folder using SUBST command. We have a Windows application which reads contents of the and performs some operations. Application does not give any error when read the file path is from actual drive. But when try to read from drive created using SUBST, it gives invalid path error. Please find the following code snippet for it. Error occurs at the last line.
hFile = CreateFile(
("\\\\?\\" + std::string(file_path,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile == INVALID_HANDLE_VALUE) {
CloseHandle(hFile);
return;
}
fd = new CFile(hFile);
Sign in to answer