I'm trying to figure out (in C#) how to download a directory with content (files and folders) in my GitHub repository through the API. Some of the articles mention Octokit.Net so i downloaded this and wrote the following lines:

var github = new GitHubClient(new ProductHeaderValue("PROJECT"), new InMemoryCredentialStore(new Credentials("xxxtokenxxx")));
    
var repositories =  github.Repository.GetAllForCurrent().Result;

var repository = repositories.Single(x => x.Name == "MyRepo");

Well i then get the repository and it works but i'm not sure where to go from here?

How can i download Folder1 (look below) containing all files and Folder2 with files in a structure to my local hard disk?

https://github.com/PROJECT/MyRepo/tree/2016-1/Folder1/Folder2

Can anyone help me in the right direction? Your help is greatly appreciated. Thanks

According to Issue #1950 download whole folder/directory from repository on Octokit, this isn't possible given the limitations of the github API. The best you can do is download the entire repo and parse through the files yourself:

var archiveBytes = await client.Repository.Content.GetArchive("octokit", "octokit.net", ArchiveFormat.Zipball);