Get Dir Files - CSharp System.IO

CSharp examples for System.IO:DirectoryInfo

Description

Get Dir Files

Demo Code


using System.IO;/*  w  ww .java  2 s.  c o  m*/
using System;

public class Main{

        public static string[] GetDirFiles(string dirFullPath, string searchPattern, SearchOption so)
        {
            if (Directory.Exists(dirFullPath))
            {
                return Directory.GetFiles(dirFullPath, searchPattern, so);
            }
            return null;
        }
        public static string[] GetDirFiles(string dirFullPath, string searchPattern)
        {
            if (Directory.Exists(dirFullPath))
            {
                return Directory.GetFiles(dirFullPath, searchPattern);
            }
            return null;
        }
        public static string[] GetDirFiles(string dirFullPath, SearchOption so)
        {
            if (Directory.Exists(dirFullPath))
            {
                return Directory.GetFiles(dirFullPath, "*.*", so);
            }
            return null;
        }
        public static string[] GetDirFiles(string dirFullPath)
        {
            if (Directory.Exists(dirFullPath))
            {
                return Directory.GetFiles(dirFullPath, "*.*", SearchOption.TopDirectoryOnly);
            }
            return null;
        }
}

Related Tutorials