Created
June 17, 2020 11:14
-
-
Save luisdeol/8189b896292598490ad383a3e6557c27 to your computer and use it in GitHub Desktop.
4.1: Listing directories and using wildcards.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
namespace ImplementDataAccess._41_PerformIoOperations | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var myDirectory = @"../../Directory"; | |
var myDirectoryInfo = new DirectoryInfo(myDirectory); | |
Console.WriteLine($"Sub-directories for: {myDirectoryInfo.Name}:"); | |
foreach (var subDirectoryInfo in myDirectoryInfo.GetDirectories()) { | |
Console.WriteLine($"- {subDirectoryInfo.FullName}"); | |
} | |
var directoriesContainingMore = myDirectoryInfo.GetDirectories("*more*"); | |
Console.WriteLine("Directories containing 'more' word:"); | |
foreach (var subDirectoryInfo in directoriesContainingMore) | |
{ | |
Console.WriteLine($"- {subDirectoryInfo.FullName}"); | |
} | |
Console.Read(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment