2
Answers

Regex for Windows File Path

Guys I have tried so many crazy Regex none worked to check something like this =>> C:\Blabla\Blabla\Blabla\Blabla\blabla.txt or ANY level of file depth meaning  C:\Blabla\Blabla\Blabla\Blabla\Blabla\Blabla\Blabla\Blabla\Blabla\Blabla\blabla\blablablabla.txt 

I mean this pattern. No server patterns. 

Regex.IsMatch (MyPath, @"^(?:[a-zA-Z]\:|\\\\[\w\.]+\\[\w.$]+)\\(?:[\w]+\\)*\w([\w.])+$")

 
Answers (2)