Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

using System.IO;
using System.Collections.Generic;

var currentDirectory = Directory.GetCurrentDirectory();
var storesDirectory = Path.Combine(currentDirectory, "stores");
var salesFiles = FindFiles(storesDirectory);

foreach (var file in salesFiles)
{
Console.WriteLine(file);
}

IEnumerable<string> FindFiles(string folderName)
{
List<string> salesFiles = new List<string>();

var foundFiles = Directory.EnumerateFiles(folderName, "*", SearchOption.AllDirectories);

foreach (var file in foundFiles)
{
// The file name will contain the full path, so only check the end of it
if (file.EndsWith("sales.json"))
{
salesFiles.Add(file);
}
}

return salesFiles;
}
11 changes: 11 additions & 0 deletions mslearn-dotnet-files.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>mslearn_dotnet_files</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>