© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•11mo ago•
25 replies
SWIMON

How do I Retrieve a file in C#

I'm writing small CLI task-tracker program, according to the projects from roadmap.sh backend section.
https://roadmap.sh/projects/task-tracker

I need to retrieve and deserialize JSON file as part of the program. I suppose it wouldn't be good practice to manually copy and paste the path. In most tutorials I see something similar to the code snippet below for accessing the file.

var currentDirectory = Directory.GetCurrentDirectory();
var jsonFilePath = Path.Combine(currentDirectory, "Data","Tasks.json");
var currentDirectory = Directory.GetCurrentDirectory();
var jsonFilePath = Path.Combine(currentDirectory, "Data","Tasks.json");



for me GetCurrentDirecory() method returns following path: "~\source\repos\TaskTrackerCLI\TaskTrackerCLI\bin\Debug\net8.0"
the Tasks.json file is inside Data folder, which is inside the project folder, as it should be.

Can anyone tell me how I should retrieve the file, what am I doing wrong?
roadmap.sh
Task Tracker CLI
Build a command line interface (CLI) to track your tasks and manage your to-do list.
Task Tracker CLI
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How do i make a c# file in vscode?
C#CC# / help
3y ago
How do I do a HTTP request in C#?
C#CC# / help
2y ago
❔ Retrieve API data in C#
C#CC# / help
3y ago
✅ How do I program in C#?
C#CC# / help
3y ago