Directory.GetFiles
doesn’t support RegEx
by default, what you can do is to filter by RegEx
on your file list. Take a look at this listing:
Regex reg = new Regex(@"^^(?!p_|t_).*");
var files = Directory.GetFiles(yourPath, "*.png; *.jpg; *.gif")
.Where(path => reg.IsMatch(path))
.ToList();
Related Contents:
- Is there a way to check if a file is in use?
- \d less efficient than [0-9]
- How do I match an entire string with a regex?
- What are regular expression Balancing Groups?
- Find and extract a number from a string
- Simple and tested online regex containing regex delimiters does not work in C# code
- Regex.Match whole words
- Using String Format to show decimal up to 2 places or simple integer
- Nested using statements in C#
- Free file locked by new Bitmap(filePath)
- Open existing file, append a single line
- How to find the most recent file in a directory using .NET, and without looping?
- regular expression for finding ‘href’ value of a link
- C# Regex Split – commas outside quotes
- How do I remove all non alphanumeric characters from a string except dash?
- Overlapping matches in Regex
- How can I strip HTML tags from a string in ASP.NET?
- Regular expression for decimal number
- determine if file is an image
- Replace only some groups with Regex
- Mirroring console output to a file
- What’s the difference between “groups” and “captures” in .NET regular expressions?
- Replace first occurrence of pattern in a string [duplicate]
- Finding quoted strings with escaped quotes in C# using a regular expression
- Regex to get NUMBER only from String
- Poor man’s “lexer” for C#
- C# Regex for Guid
- Regex: C# extract text within double quotes
- Getting overlapping regex matches in C#
- C# Regex Split – everything inside square brackets
- Why \b does not match word using .net regex
- How can I create a temp file with a specific extension with .NET?
- How to check if a file exists in a folder?
- Adding elements to an xml file in C#
- C# code to linkify urls in a string
- Number of occurrences of a character in a string [duplicate]
- Regular Expression for password validation
- Regex replace multiple groups
- Regex: Repeated capturing groups
- Standalone numbers Regex?
- RegEx – reusing subexpressions
- C# Regex: Checking for “a-z” and “A-Z”
- Regex to match a word with + (plus) signs
- How to insert characters to a file using C#
- C# – Regex for file paths e.g. C:\test\test.exe
- Count regex replaces (C#)
- What is the difference between File and FileInfo in C#?
- Match word that ends with “Id” using regular expression?
- Why doesn’t $ in .NET multiline regular expressions match CRLF?
- C# Regex.Split: Removing empty results