Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / December 2004

Tip: Looking for answers? Try searching our database.

Problem creating FileInfo Array

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Antonio - 23 Nov 2004 14:36 GMT
Good morning,
I've the following file system :

C: -> HTML -> Aziende -> Azienda_1 -> a.jpg
             -> Azienda_2 -> a.jpg
                             ...
             -> Azienda_N -> a.jpg

my desire is to create an array of fileinfo containing the a.jpg ,
a.jpg , ... , a.jpg
in a way that I could bind this to a datagrid to show some properties
of these files.
I tried the following but it is not ok

    FileInfo[] fi ;   
    DirectoryInfo dirInfo = new DirectoryInfo("C:\HTML\Aziende");
    DirectoryInfo[] di = dirInfo.GetDirectories();
    int i = 0;
    fi = new FileInfo[1000];   
    foreach (DirectoryInfo dri in di)
    {
     fi[i++] = dri.GetFiles("a.jpg")[0];
    }

the error is  System.IndexOutOfRangeException

could you help me to solve this problem and to crate the array of
FileInfo types ??

Thanks ...

    Antonio
Maqsood Ahmed - 17 Dec 2004 12:33 GMT
I guess the problem is not in create FileInfo array. Its in
dri.GetFiles("filename")[0]. Some directories might not have "a.jpg"
file, and return a zero length FileInfo array. You need to check if
length of the return array is greater than zero.
Cheers!!

Maqsood Ahmed
Kolachi Advanced Technologies
http://www.kolachi.net

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.