Sharpen.FilePath.List C# (CSharp) Méthode

List() public méthode

public List ( FilenameFilter filter ) : string[]
filter FilenameFilter
Résultat string[]
		public string[] List (FilenameFilter 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;
			}
		}

Same methods

FilePath::List ( ) : string[]

Usage Example

		/// <exception cref="System.IO.IOException"></exception>
		public static void CopyFolder(FilePath src, FilePath dest)
		{
			if (src.IsDirectory())
			{
				//if directory not exists, create it
				if (!dest.Exists())
				{
					dest.Mkdir();
				}
				//list all the directory contents
				string[] files = src.List();
				foreach (string file in files)
				{
					//construct the src and dest file structure
					FilePath srcFile = new FilePath(src, file);
					FilePath destFile = new FilePath(dest, file);
					//recursive copy
					CopyFolder(srcFile, destFile);
				}
			}
			else
			{
				CopyFile(src, dest);
			}
		}