silentB4thedawn
June 6th, 2009, 11:01 PM
Here's the code that I'm currently using in VS C# 2010:
// update listbox
DirectoryInfo dir = new DirectoryInfo((Application.StartupPath + "\\CustomerCollectionData\\"));
// create array containing filenames
FileInfo[] file = dir.GetFiles();
// print out the file names
FileInfo fiTemp;
foreach (fiTemp in file)
{
listBox1.Items.Add(fiTemp.Name);
}
I get an error under the "foreach (fiTemp in file)" line; specifically red-underlined "fiTemp" & "in" saying:
"Type or namespace name 'fiTemp' could not be found"
(under "fiTemp")
and
"Type and identifier are both required in a foreach statement"
(under "in")
According to my research on this topic, the syntax should be right, unless I missed something...
Anyone know what the issue is?
// update listbox
DirectoryInfo dir = new DirectoryInfo((Application.StartupPath + "\\CustomerCollectionData\\"));
// create array containing filenames
FileInfo[] file = dir.GetFiles();
// print out the file names
FileInfo fiTemp;
foreach (fiTemp in file)
{
listBox1.Items.Add(fiTemp.Name);
}
I get an error under the "foreach (fiTemp in file)" line; specifically red-underlined "fiTemp" & "in" saying:
"Type or namespace name 'fiTemp' could not be found"
(under "fiTemp")
and
"Type and identifier are both required in a foreach statement"
(under "in")
According to my research on this topic, the syntax should be right, unless I missed something...
Anyone know what the issue is?