I am using “GetFiles” to extract files in a specified folder as shown below:
Directory.GetFiles(_dirPath, File_Filter);
This creates a string array which is fine but now I need to do something similar but create a Tuple array where each Tuple holds the full path including filename and also just the filename. So at the moment I have this in my string
C:\temp\test.txt
The new code needs to create a Tuple where each one looks similar to this:
Item1 = C:\temp\test.txt
Item2 = test.txt
I’m guessing I could do this this with a bit of Linq but am not sure. Speed and efficiency is too much of a problem as the lists will be very small.
You should use
Directory.EnumerateFiles
with LINQ which can improve performance if you don't need to consume all files. Then use thePath
class: