Why does it complain about it not being able to convert a string array to a string when the values are strings within a string array
Code:
int i;
string[] Filenames;
OpenFileDialog UnConvertedFilesList = new OpenFileDialog();
if (UnConvertedFilesList.ShowDialog() == DialogResult.OK)
{
foreach (string FileName in UnConvertedFilesList.FileNames)
{
//Right Here
Filenames[i] = Filenames;
AudioFiles_listbox.Items.Add(FileName);
i++;
}
}//if
else
{
MessageBox.Show("File does not exist");
}
edit: that line to Changed Filenames[i] = FileName
Now it says “Use of unassigned local variable ‘Filenames’ and same thing for i
Their defined at the top of the function.
You have an extra “s” on your name there:
should be:
More than that, though, your Filenames[] array is currently
null. Once you fix your first problem you’ll have that to contend with. My recommendation there is to skip using the array entirely and just go directly to the AudioFiles_listbox. And once you do that, you can go right for the Listbox’s AddRange method: