By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,573 Members | 1,786 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,573 IT Pros & Developers. It's quick & easy.

Sorting files by size

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Niels,

I do not see the sense, however that is not important, using the
directoryinfo class and the file move, this should be a piece of cake.

http://msdn.microsoft.com/library/de...classtopic.asp

I took first the wrong link, maybe you need that as well, you see the file
move in that.
http://msdn.microsoft.com/library/de...classtopic.asp

I assume that you know how to sort an array

I hope this helps?

Cor
Nov 21 '05 #2

P: n/a
"Niels" <ni****@hollandridderkerk.nl> schrieb:
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/groups?selm...K2MSFTNGP10.ph
x.gbl>

The length of a file can be determined with 'FileLen' or 'FileInfo.Length'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #3

P: n/a
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

"Niels" wrote:
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

Nov 21 '05 #4

P: n/a
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).
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.