Click here to Skip to main content
15,906,567 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
why does this code return
"line 8, Argument 1: cannot convert 
from'System.Collections.Generic.List<string>' to 'string'


What I have tried:

C#
List<string> strs1 = new List<string>();
string[] strArrays = Directory.GetFiles(str1);
for (int j = 0; j < (int)strArrays.Length; j++)
{
    strs1.Add(Path.GetFileName(strArrays[j]));
}
richTextBox1.AppendText(string.Concat("New files in folder", str1, " : "));
richTextBox1.AppendText(strs1);
Posted
Updated 17-Jul-18 6:30am
v2

You have declared strs1 as a List<string>, but you are trying to use it as a simple string. You also have a variable declared elsewhere named str1, maybe that is causing the confusion.
 
Share this answer
 
Because the AppendText [^] method of a RichTextBox expects a string parameter.

You are passing a list of strings
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900