Is there a method similar to Directory.EnumerateFiles
that will return the relative paths of each file in a directory instead of their absolute paths?
I'm trying to fetch all files from the current directory, the paths will later be used to log into the terminal with some diagnostics. This is how I'm doing it right now, but the issue is that this returns the files with their absolute paths:
var allFiles = Directory.EnumerateFiles(Directory.GetCurrentDirectory(), "*", SearchOption.AllDirectories);
I could then substring each of them to get their relative paths, but that would require allocating new strings for each path name which is not ideal with the amount of files we have to process. I needed to get the path of the file relative to the current directory so as to not break the formatting of our diagnostics when the absolute path is too large.
We need a way to fetch the relative paths directly instead of their absolute paths.