|
-
June 6th, 2009, 11:01 PM
#1
Populating listbox with file names
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|