On 21 Mar 2006 11:09:22 -0800, theinvisibleGhost wrote:
Subject says it all really.
I'm being passed a string, and I'm wondering if theres an easy
way to determine what exactly the string points at?
Depends on what you really want to do. If you want to check that your
string is the path of an existing file on your hard drive or on a network
drive, you could use File.Exist() (and handle the exceptions in case the
string is not a valid path string). For drives and directories, use
Directory.Exist(). The other methods of the Directory class will help you
to determine if your dealing with a path to a drive or to a folder. For
Url, use the Uri class and catch exceptions in case the string is not a
valid Uri.
If you just want to now wether the string is a valid path string (even if
it doesn't point to any file of folder actually existing on your hard
drive), then you could use the various methods of the Path class to do
that.
Else, you can always roll on your own regex to parse the string (actually,
there are probably many examples of regex that could do that on the web)
For onions though i'm not too sure.