Determine whether a folder is on the local computer
Posted on 2016-09-12
My VB 2008 application has configuration files which may be stored either locally or in a server folder. However, if they're stored on the server, the issue arises that a laptop might be used when the server is not accessible. I want to have a fallback process that will determine, if the file is not found (that is, if File.Exists returns False), if it's looking for a server location; if so, I would assume that the server is inaccessible and check a secondary location for the configuration information. If we're looking at the local computer, then I would assume the file doesn't exist, either because it's a new installation or because someone wiped out the file, and I would reinitialize.
I'm not sure how to determine whether the folder location is on the local computer or a server. If it starts with a "\\", of course, that would be a strong indicator of a network location. But a drive letter other than C: is ambiguous; it could be a second physical or logical drive, or it could be a mapped network drive. Can you suggest a way to know whether it's local or network?