I am getting directories from users and storing in databases. I really need validation whether they are correct. Right now I have the list of directories which can be used in a valid manner.
Only drive name - (with and without trailing forward or backward slash)
X:
Drive with direcory - (with forward or backward slashes and with and without trailing forward or backward slash)
X:\Test
Only two forward or backward slashes (without trailing forward or backward slash)
\\teela\admin$
IP address - (with and without trailing forward or backward slash)
\\192.168.1.13
IP address with direcory - (with forward or backward slashes and with and without trailing forward or backward slash)
\\192.168.1.13\test
Can you please tell me if this is the complete list or we can write the directories in another ways?
\\
to make them an UNC path. Also UNC paths consist of a server and a share name .. - Joey 2012-04-03 19:44
You can use the NDepend.Helpers.FileDirectoryPath library to handle this for you. It includes a path validity check API.