How to check the path to a WINAPI file - is it a disk or file or directory?

How to check the path to a WINAPI file - is it a disk or file or directory?

+5
source share
3 answers

Use GetFileAttributes .

Edit: You can also check SHGetFileInfo

+6
source

You can try FindFirstFile:

http://msdn.microsoft.com/en-us/library/aa364418%28v=VS.85%29.aspx

Once you have the search data (passed as the second argument to this function):

if(result->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
    //file is a directory
}
else
{
    //file is not a directory
}

In addition, to find out if there is something to the volume, you can try something like:

if(result->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
{
    if(result->dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)
    {
        //path is a volume; try using GetVolumeNameForVolumeMountPoint for info
    }
}

NTN

+2
source

, ? UNC "\\ server\share\file_path" .

Out of curiosity, I looked at it. Based on this MSDN article, Naming Files, Paths, and Namespaces , it seems like my advice is exactly how he says it should be done.

+1
source

All Articles