How to find out if a file is local or from the network
-
Can someone point me in a direction on how to solve this problem? I have to be able to find out if a file I am pointing to is local or not. I can point to a file through the network neighborhood or through a networked drive. I think finding out if the file was accessed through the network neighborhood would not be a problem, its when I map a network drive. Once the drive is mapped, it is given a drive letter like any other local drive. Help would be much appreciated. PS. This seems promising... http://www.codeproject.com/csharp/mapnetdrive.asp[^] My idea was to try to unmap the drive and if my attempt fails, the drive must be local. The problem is, that if I unmap a drive with a username:pw, I have to remap it with the same username:pw which I may not have. For the network neighborhood, Does checking the root of a file work? ex. \\NAME\c$
-
Can someone point me in a direction on how to solve this problem? I have to be able to find out if a file I am pointing to is local or not. I can point to a file through the network neighborhood or through a networked drive. I think finding out if the file was accessed through the network neighborhood would not be a problem, its when I map a network drive. Once the drive is mapped, it is given a drive letter like any other local drive. Help would be much appreciated. PS. This seems promising... http://www.codeproject.com/csharp/mapnetdrive.asp[^] My idea was to try to unmap the drive and if my attempt fails, the drive must be local. The problem is, that if I unmap a drive with a username:pw, I have to remap it with the same username:pw which I may not have. For the network neighborhood, Does checking the root of a file work? ex. \\NAME\c$
One possible solution is to use the WIN32 API function GetDriveType. By passing in the drive as a string, the function will return the drive type as shown below. int nDriveType = GetDriveType("Z:\\"); if (nDriveType == DRIVE_REMOTE) MessageBox(NULL, "Network Drive", "Network Drive", MB_OK | MB_ICONINFORMATION); Hope this helps.
-
One possible solution is to use the WIN32 API function GetDriveType. By passing in the drive as a string, the function will return the drive type as shown below. int nDriveType = GetDriveType("Z:\\"); if (nDriveType == DRIVE_REMOTE) MessageBox(NULL, "Network Drive", "Network Drive", MB_OK | MB_ICONINFORMATION); Hope this helps.