Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to check if string is valid(doesn't have invalid chars) unix path using c# without mono?
Posted
Comments
Sergey Alexandrovich Kryukov 21-Dec-11 16:47pm    
Does it mean "some path name which could be a valid path name in Unix file systems" or "path name corresponding to a file or directory which actually exist"? If this is the second option, what is the type of your connection to Unix system do you have?
--SA
apaka 21-Dec-11 16:52pm    
It means some path name which could be a valid path name in Unix file systems.

1 solution

First you need to figure out the sub-set of valid characters and maximum allowed file length in the system. Start here: http://en.wikipedia.org/wiki/Filename[^].

I would first check up the length and then validate the sequence using Regular Expressions, see:
http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx[^].
http://en.wikipedia.org/wiki/Regular_expression[^].

This is easy but would need some time to put it right. For example, you can have '.' or '..' in combinations with '/' or file name characters. (This is all true for Windows, but there are many people who incorrectly think it is not.)

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900