How to return filelist?

L

Lasse Edsvik

Hello

Is it possible to return a list of files from a function?


private ??? test()
{

DirectoryInfo dir = new DirectoryInfo(Server.MapPath("img/"));

return dir.GetFiles("*.jpg");

}

or something?

/Lasse
 
S

Shiva

DirectroyInfo.GetFiles returns an array of FileInfo. So, the return type for
your test() method would be FileInfo[].

Also, check out Directory.GetFiles() which gives you an array of strings
(file names).

HTH.

Hello

Is it possible to return a list of files from a function?


private ??? test()
{

DirectoryInfo dir = new DirectoryInfo(Server.MapPath("img/"));

return dir.GetFiles("*.jpg");

}

or something?

/Lasse
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top