Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem creating FileInfo Array

Reply
Thread Tools

Problem creating FileInfo Array

 
 
Antonio
Guest
Posts: n/a
 
      11-23-2004
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
 
Reply With Quote
 
 
 
 
Maqsood Ahmed
Guest
Posts: n/a
 
      12-17-2004
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem creating FileInfo Array Antonio ASP .Net 1 11-23-2004 02:41 PM
FileInfo from http =?Utf-8?B?U2VubmE=?= ASP .Net 3 09-13-2004 11:21 AM
Re: Results from fileinfo - how to return, case-sensitive Martin Dechev ASP .Net 0 04-02-2004 01:33 PM
Ordering FileInfo[] by date Craig Douglas ASP .Net 0 01-30-2004 11:54 AM
FileInfo NameSpace and methods Do ASP .Net 1 12-01-2003 06:02 AM



Advertisments