© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
8 replies
js

problem with console writeline

Console.WriteLine("Please select a file to load.");

string[] filePaths = Directory.GetFiles(@"C:\Users\Joe\Documents\Uni\Programming Portfolio\Summative4\Summative4", "*.mark");

int count1 = 1;

foreach (string file in filePaths)
{
    Console.WriteLine($"{count1}. ",Path.GetFileName(file));
    count1 = count1 + 1;
}
string selectedFile = Console.ReadLine();
Console.WriteLine("Please select a file to load.");

string[] filePaths = Directory.GetFiles(@"C:\Users\Joe\Documents\Uni\Programming Portfolio\Summative4\Summative4", "*.mark");

int count1 = 1;

foreach (string file in filePaths)
{
    Console.WriteLine($"{count1}. ",Path.GetFileName(file));
    count1 = count1 + 1;
}
string selectedFile = Console.ReadLine();

when i run the program its printing all the filenames fine but not the number before each file (count1)
image.png
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

❔ Console.WriteLine
C#CC# / help
4y ago
✅ Console.WriteLine Broken
C#CC# / help
4mo ago
Console.WriteLine does nothing
C#CC# / help
2y ago