Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ADIR and ASORT for .NET ?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01020162
Message ID:
01021465
Vues:
17
Finally I was able to figure out what to do and how.

First I was confused with the two GetFiles() approaches. Though both of them create one-dimentional arrays, those arrays are very different:
Dim aFiles()
aFiles = System.IO.Directory.GetFiles(BackupDirectory, "*.*")
' Create Array of file names only

Dim dirInfo As New System.IO.DirectoryInfo(BackupDirectory)
Dim aFilesInfo() As System.IO.FileInfo = dirInfo.GetFiles("*.*")
' Creates Array of file OBJECTS having all file attributes accessible via:
'  aFilesInfo(ia).Property_name
The first one is used in VFPToolkit for NEt and allows to use array.sort and VFP asort(), but by names only.
The second one does not implement the IComparable interface, and one cannot pass the array to the array.sort method. So it is a little bit tricky to sort items by particular property. It is explained in "Sort FileInfo and DirectoryInfo objects",
http://vb2themax.com/ShowContent.aspx?ID=38f32e71-ab8e-449d-9557-8417bd31c350.

Also they introduce there the FileSystemComparer class that though bulky may be used in my case.

Thanks to all of you for ideas and advices.



>Yuri,
>I think you fail to see my point.
>It is true that VFP has a nice function to get filenames and last modified date into an array (ADIR) and VFP also has a nice function that can sort a 2-dim array on any column. The .NET framework does not have these two nice functions (or methods) (maybe they will in v2.0). The face the .NET does not have these functions built in does not prevent you from making your own functions that does the same thing. You say that in .NET you have to go through the entire array, well I am sure that has to be done in VFP also but it is done behind the scenes (in the functions ADIR and/or ASORT).
>Some one posted a link to a website (guysfromrolla I think). This article sounds very promising and should solve your problem.
>
>Einar
>
>>Einar,
>>
>>As far as I see, there is a big difference, and this difference is critical.
>>VFP adir is two-dimentional array, and VFP asort may sort on any column in the array. Cannot see anything similar in VB.NET so far: it deals with one-dimentional array, and for file names only.
>>
>>>Correct, but all the files (or elements in the array) has to be scanned in VFP also. The only difference is that it is cleverly hidden behind a function call (ASORT).
>>>Did you search CodeProject or any other sites for a way to do this (I am sure someone else has done something like this)?
>>>
>>>>Probably it could be done this way, but to create the second array with dates, one needs to scan all files anyway.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform