Bouzid Aissaoui

Bouzid Aissaoui

  • NA
  • 4
  • 3.2k

Regex for Windows File Path

Dec 1 2015 12:37 PM

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)