C#C
C#2y ago
zzz

reading files from a directory

using System.IO;

namespace Program
{
    class program
    {
        public static void FileLoader()
        {
            string[] filePaths = Directory.GetFiles(@"C:\Users\joesm\Source\Repos\441101-2324-digital-portfolio-jsd6666\Summative 4\", "*.mark", SearchOption.TopDirectoryOnly);
            for (int i = 0; i < filePaths.Length; i++)
            {
                Console.WriteLine($"{i + 1}. {filePaths[i]}");
            }
            int fileSelect = int.Parse(Console.ReadLine());
        }
        public static void Main()
        {
            Console.WriteLine("Please select a file to load.");
            FileLoader();
        }
    }
}

its showing me the file names with the directory included, i just want it to display the file name on each line without the directory??
image.png
Was this page helpful?