What are the different ways to use directories in Windows?

Go To StackoverFlow.com

1

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?

2012-04-03 19:40
by om471987
........\this\is\a\relative\pat - Steve 2012-04-03 19:43
IP addresses as you wrote them there are just a normal relative path. You need to prepend \\ to make them an UNC path. Also UNC paths consist of a server and a share name .. - Joey 2012-04-03 19:44
Thanks Steve I will make sure people cannot enter relative path :) thank you so muc - om471987 2012-04-03 19:59
Thanks Joey I will make sure ppl can only add absolute paths and not relative.. - om471987 2012-04-03 20:04
You also need to account for environemental variables like %HOMEPATH% or %APPDATA% Check out http://libertyboy.free.fr/computing/reference/envariables/index.ph - Murtnowski 2012-04-03 20:17
Thanks Mutnowski, environment variables are absolute paths but only problem is I need to check if they are set before use them. Thanks a lot ma - om471987 2012-04-03 20:28


2

You can use the NDepend.Helpers.FileDirectoryPath library to handle this for you. It includes a path validity check API.

2012-04-03 20:29
by markyd13
Ads