How to check with WINAPI file path is disk or file or directory?
UNC paths. Universal naming convention (UNC) paths, which are used to access network resources, have the following format: A server or host name, which is prefaced by \\ . The server name can be a NetBIOS machine name or an IP/FQDN address (IPv4 as well as v6 are supported).
Click the Start button and then click Computer, click to open the location of the desired file, hold down the Shift key and right-click the file. Copy As Path: Click this option to paste the full file path into a document. Properties: Click this option to immediately view the full file path (location).
If we want to check the current directory of the R script, we can use getwd( ) function. For getwd( ), no need to pass any parameters. If we run this function we will get the current working directory or current path of the R script. To change the current working directory we need to use a function called setwd( ).
C++ program to find a specific file in a directory opendir-It will open directory stream and take a string as a parameter and return pointer of type DIR if it successfully opens directory or returns a NULL pointer if it is not able to open directory. closedir-It will close the directory.
Use GetFileAttributes.
Edit: You can also check SHGetFileInfo
Could try FindFirstFile:
http://msdn.microsoft.com/en-us/library/aa364418%28v=VS.85%29.aspx
Once you have the find data (passed as the 2nd argument to that function):
if(result->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
//file is a directory
}
else
{
//file is not a directory
}
Also, to see if something is a volume, could 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
}
}
HTH
See if the path has a drive letter in front of it? All UNC's take the form "\\server\share\file_path" No drive letter.
Out of curiousity I looked this up. Based on this MSDN article Naming Files, Paths, and Namespaces, it seems my advice is exactly how it says it should be done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With