Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADIR and ASORT for .NET ?
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01020162
Message ID:
01020936
Views:
19
Yuri,
Have you looked at System.IO.Directory.GetFiles()?
System.Collections.Specialized.StringCollection myFileCollection = new System.Collections.Specialized.StringCollection();
string myPath = @"c:\it\";
string myFileName = "yo*.*";

foreach (string myFile in System.IO.Directory.GetFiles(myPath, myFileName))
{
	myFileCollection.Add(myFile);
}
One of the overloads for GetFiles() allows you to specify a search pattern. I have not done any speed tests on this.
Hope it helps. If find it hard to belive that .NET is slower than VFP when it comes to this. What file system are the files on?
Sorry about the C# code, but it should be easy to convert to VB.NET.

Einar



>I need to scan several directories containing about 10000 files each and for files created, say, more than 2 weeks ago during the day hours prior to the current time. There could be about 100 files that should be erased. With VFP ADIR() it is quite easy to do:
>
>If  adir(atmp,”*.*”)>0
>     =asort(atmp,3)
>     ia=1
>     do while atmp[ia,3]<date()-14
>       if additional_timecondition
>          erase (atmp[ia,1])
>       endif
>
>      ia=ia+1
>
>   enddo
>endif
>
>
>And it takes about 1-5 seconds.
>
>But I cannot figure out how to do it wisely in VB.NET: the collection object like Scripting.FileSystemObject does not give the ability to sort. Therefore it requires scanning all the files, and checking the date of each of them. It takes about 2-3 minutes per directory.
>
>Adding the VFP Toolkit for .NET requires additional installation on the PC, and it is not allowed at the time.
>
>Has anyone a suitable solution?
Semper ubi sub ubi.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform