Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Foreach FileInfo in DirectoryInfo

Posted on 2010-08-29
3
Medium Priority
?
1,211 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 1000 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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

715 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