Sorting files by size

  • Thread starter Thread starter Niels
  • Start date Start date
N

Niels

Hello,

I want to make a program that moves files from a main directory to a
sub directory.
Suggeset that i have 2000 files, the program will create 4 sub
directory's and move 500 files to each directory.

I think until this point it wont be a problem, but.... I want the
files to be ordered by filesize.
I mean that the first 500 files that will be moved will have the
smallest filesize and so on.

I dan't know if it is possible and ofcourse how to do it...

Is there anyone who can provide me a solution or a push in the good
direction???

Thanks in advance
 
Niels said:
I want to make a program that moves files from a main directory to a
sub directory.
Suggeset that i have 2000 files, the program will create 4 sub
directory's and move 500 files to each directory.

I think until this point it wont be a problem, but.... I want the
files to be ordered by filesize.

You can adapt the code contained in the following post:

<URL:http://groups.google.com/[email protected]
x.gbl>

The length of a file can be determined with 'FileLen' or 'FileInfo.Length'.
 
There is an excellent example in Microsoft's "Visual Basic.Net Programmer's
Cookbook" under ArrayLists, Sorting. Basically use and array list with a
structure of Filename, filesize, and what everelse you want. Then add the
fileinfo to an arraylist of the structures. Then create a public class the
iimplements IComparer and include a sub the implements
System.Collections.Icomparer.Compare
 
Thank you all for your reply,

I hoped it would be easyer (i'am still a beginner)and i dont
understand what to do (I have tried different to apply the things you
guys gave to me, but it is still to difficult for me).
 

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

Back
Top