Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Commit after Import from Git #2

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net5.0/files-module.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
42 changes: 42 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/files-module.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/files-module.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/files-module.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
45 changes: 45 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.IO;
using System.Collections.Generic;

namespace files_module
{
class Program
{
static void Main(string[] args)
{
// Pass in the name of the folder "stores" to the FindFiles method
var salesFiles = FindFiles("stores");

// For each file that matched the search criteria in the FindFiles method
// it was added to "salesFile" - and we now print each filename and its location
foreach (var file in salesFiles)
{
Console.WriteLine(file);
}
}

// Create a new function called FindFiles that takes a folderName parameter.
static IEnumerable<string> FindFiles(string folderName)
{
// Create a new list of type strings named "salesFiles"
List<string> salesFiles = new List<string>();

// Searches the directory location specified and returns the full file names
// and the relevant file paths
var foundFiles = Directory.EnumerateFiles(folderName, "*", SearchOption.AllDirectories);

// Search and check each file in "foundFiles" against parameter
foreach (var file in foundFiles)
{
// The file name will contain the full path so only check the end of it and if a match
// add this file to "salesFile"
if (file.EndsWith("sales.json"))
{
salesFiles.Add(file);
}
}
return salesFiles; // Return the contents of "salesfile" to memory
}//findFiles
}//Program
}//files_module
9 changes: 9 additions & 0 deletions files-module.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>files_module</RootNamespace>
</PropertyGroup>

</Project>