-1

So i want to name of the folders printed found in my executable location.

var foldersFound = Directory.GetDirectories(AppDomain.CurrentDomain.BaseDirectory, "test", SearchOption.AllDirectories);
Debug.Print(foldersFound);

However i get an error saying

Error   CS1503  Argument 1: cannot convert from 'string[]' to 'string'  

What am i doing wrong?

4

3 回答 3

0

do a foreach loop and print every item from the foldersFound array. The return type of GetDirectories is an array so you can not print that.

Should look like this:

foreach(var folder in foldersFound){
   Debug.Print(folder);
}
于 2018-05-31T21:42:30.860 回答
0

Directory.GetDirectories() returns a string array. If you want to print all of the directories then you need to enumerate them

var foldersFound = 
Directory.GetDirectories(AppDomain.CurrentDomain.BaseDirectory, "test", SSearchOption.AllDirectories);
    foreach (var folder in foldersFound)
    {
        Debug.Print(folder);
    }

Or you can use string.Join() to concatenate them

Debug.Print(string.Join(",",foldersFound));
于 2018-05-31T21:43:11.280 回答
0

What am i doing wrong?

Debug.Print() is expecting string type and not array of strings.

var foldersFound = 
Directory.GetDirectories(AppDomain.CurrentDomain.BaseDirectory, "test", SSearchOption.AllDirectories);

Is returning strings array. Just try to iterate the strings array and print one by one.

于 2018-05-31T21:49:24.077 回答