First you can get the absolute path, and then list the files inside the directory matching the pattern:
// input string rootDir = @"c:\foo\bar"; string originalPattern = @"..\blah\*.cpp"; // Get directory and file parts of complete relative pattern string pattern = Path.GetFileName (originalPattern); string relDir = originalPattern.Substring ( 0, originalPattern.Length - pattern.Length ); // Get absolute path (root+relative) string absPath = Path.GetFullPath ( Path.Combine ( rootDir ,relDir ) ); // Search files mathing the pattern string[] files = Directory.GetFiles ( absPath, pattern, SearchOption.TopDirectoryOnly );
Stephan bauer
source share