public File[] ListFiles(IFilenameFilter filter) { String[] ss = List(); if (ss == null) { return(null); } List <File> v = new List <File>(); for (int i = 0; i < ss.Length; i++) { if ((filter == null) || filter.Accept(this, ss[i])) { v.Add(new File(ss[i], this)); } } return(v.ToArray()); }
public string[] List(IFilenameFilter filter) { try { if (IsFile()) { return(null); } List <string> list = new List <string> (); foreach (string filePth in Directory.GetFileSystemEntries(_path)) { string fileName = Path.GetFileName(filePth); if ((filter == null) || filter.Accept(this, fileName)) { list.Add(fileName); } } return(list.ToArray()); } catch { return(null); } }
public string[] List (IFilenameFilter filter) { try { if (IsFile ()) return null; List<string> list = new List<string> (); foreach (string filePth in Directory.GetFileSystemEntries (_path)) { string fileName = Path.GetFileName (filePth); if ((filter == null) || filter.Accept (this, fileName)) { list.Add (fileName); } } return list.ToArray (); } catch { return null; } }
public File[] ListFiles(IFilenameFilter filter) { String[] ss = List(); if (ss == null) return null; List<File> v = new List<File>(); for (int i = 0; i < ss.Length; i++) { if ((filter == null) || filter.Accept(this, ss[i])) { v.Add(new File(ss[i], this)); } } return v.ToArray(); }
public bool ShouldInclude(string basepath, string filename, out IFilenameFilter match) { match = null; basepath = Utility.AppendDirSeparator(basepath); if (!filename.StartsWith(basepath, Utility.ClientFilenameStringComparision)) return false; //All paths start with a slash, because this eases filter creation //Eg. filter "\Dir\" would only match folders with the name "Dir", where "Dir\" would also match "\MyDir\" //If the leading slash/backslash is missing, it becomes difficult to prevent partial matches. string relpath = filename.Substring(basepath.Length - 1); //Run through each filter, test for relpath and full path foreach (IFilenameFilter filter in m_filters) if (filter.Match(relpath) || filter.Match(filename)) { match = filter; return filter.Include; } return true; }