C# List of Files

Hi everyone, is there a way to make a List of Files instead of an array? I want to be able to add and remove from the list. I tried creating one but I keep getting this error cannot convert type string to list < string >

//cannot convert string[] to list <string>
public list <string> Examplefiles = Directory.GetFiles(Application.dataPath);

It’s because Directory.GetFiles(string) return an array of strings.

So you can do this :

public string[] exampleFiles = Directory.GetFiles(Application.dataPath);
List<string> lstExampleFiles = new List<string>();
lstExampleFiles.AddRange( exampleFiles );

I think this can work

Some documentation on AddRange here