Solved

Foreach FileInfo in DirectoryInfo

Posted on 2010-08-29
3
1,205 Views
Last Modified: 2012-05-10
Hi,

I understood ,  

arr= { 2,4,6,7,2,7,8};
foreach( Int  temp in  arr)    : So this code will iterates with numbers  foreach integer in  arr.
this is true bcoz it is iterating on integets ,but  for this code.

foreach( FileInfo temp in DirectoryInfo )   :    I did not understood this code  

Do directoryinfo contains fileinformation , I am not able to what is the hierarchy.
and the code why it is correct.
Thankyou

Friends Can you please explain  in detail.  
0
Comment
Question by:N_Sri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Accepted Solution

by:
Jini Jose earned 250 total points
ID: 33554338
no directoryinfo contains the directory informations.


here is the sample

DirectoryInfo din = new DirectoryInfo("C:\");
            FileInfo[] fils = din.GetFiles();
            foreach (FileInfo f in fils)
            {
                //do your code
            }
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 250 total points
ID: 33554343
DirectoryInfo would need to be an enumerable source of FileInfo...

*If that is the actual code then it was a very poor choice in naming the variable!

You'd normally see something more like this:

    DirectoryInfo di = new DirectoryInfo(@"c:\some\path");
    foreach(FileInfo fi in di.GetFiles("*.txt"))
    {
        // ... do something with "fi" ...
    }
0
 

Author Closing Comment

by:N_Sri
ID: 33554372
Perfect. Thankyou
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question