This line won't work because folderName
is a string (and does not have a GetFiles
method):
FileInfo[] Files = folderName.GetFiles("*.txt");
The second error is occurring because the file
variable is a string
containing the filename. You don't need to call file.Name
, just try the following:
startupinfo.Items.Add(file);