I'm looking for a pretty easy way to search a folder for all contained
files with a specific extension and show the filenames in a listbox or
sth similar.
How can do that without using an OpenFileDialog?
Cheers,
Merrit
[DllImport("kernel32", CharSet=CharSet.Unicode)]
public static extern IntPtr FindFirstFile(string lpFileName, out
WIN32_FIND_DATA lpFindFileData);
[DllImport("kernel32", CharSet=CharSet.Unicode)]
public static extern bool FindNextFile(IntPtr hFindFile, out
WIN32_FIND_DATA lpFindFileData);
Hope this helps,
Cheers,
Arun.
www.innasite.com
Returns an array of strings with the full paths of matching files in the
specified folder.
Peter
--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://www.peterfoot.net |
http://www.opennetcf.org
"Merrit" <m.kr...@fhtw-berlin.de> wrote in message
news:3h7o1sF...@news.dfncis.de...
Cheers,
Merrit
And how to get them sorted by Date or by Size ?
thanx.
Paul T.
"Cyrille37" <cyri...@nospam.net> wrote in message
news:%23bcoWcm...@TK2MSFTNGP10.phx.gbl...
Here is example how to sort files by its size:
private class SizeSorter : IComparer
{
int IComparer.Compare(object a, object b)
{
FileInfo afi = new FileInfo(a as string);
FileInfo bfi = new FileInfo(b as string);
return afi.Length.CompareTo(bfi.Length);
}
}
...
string [] f = Directory.GetFiles("currentdir", "*.*");
ArrayList al = new ArrayList(f);
al.Sort(new SizeSorter());
"al" will contain the sorted files.
--
Sergey Bogdanov
http://www.sergeybogdanov.com
Paul G. Tobey [eMVP] wrote:
> You'll have to sort them, using what you learned in your programming classes
> in college...
>
> Paul T.
>
> "Cyrille37" <cyri...@nospam.net> wrote in message
> news:%23bcoWcm...@TK2MSFTNGP10.phx.gbl...
> Peter Foot [MVP] a йcrit :