I'm using the following code to obtain information about a file system directory:
LPCTSTR pStrPath = L"D:\\1";
WIN32_FIND_DATA wfd;
HANDLE hDummy = ::FindFirstFile(pStrPath, &wfd);
if(hDummy != INVALID_HANDLE_VALUE)
{
//Use 'wfd' info
//...
::FindClose(hDummy);
}
else
{
int error = ::GetLastError();
}
The code works just fine, unless I specify a root path:
D:\
- error codeERROR_FILE_NOT_FOUND
D:
- error codeERROR_FILE_NOT_FOUND
\\SRVR-1\share
- error codeERROR_BAD_NET_NAME
\\SRVR-1\share\
- error codeERROR_BAD_NET_NAME
\\SRVR-1\HiddenShare$
- error codeERROR_BAD_NET_NAME
But it works in the following cases:
D:\1
- no error\\SRVR-1\share\1
- no error\\SRVR-1\HiddenShare$\1
- no error
Any idea why?
FindFirstFile
can't return information about it. You can use calls likeGetVolumeInformation
andGetDiskFreeSpaceEx
to find out various things about a volume. – TussisGetFileAttributesEx
for the attributes. That API doesn't seem to treat root path differently from any other path. – AstrogationPathIsRoot()
– Replevin.
entry (as Jonathan pointed out, root dirs are special) – Dalesman