Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi There,

I am in need of help. I have a list of files that I want to write to 4 folders according to their file size. Is it possible to do this in vb.net?

thanks.
Posted

It is possible, you have to just check the file size first and after that you can separate them with if case by size as you want.

Check the follows:
How to: Determine a File's Size in Visual Basic[^]

VB
Dim infoReader As System.IO.FileInfo
infoReader = My.Computer.FileSystem.GetFileInfo("C:\testfile.txt")
MsgBox("File is " & infoReader.Length & " bytes.")


You can use this as the follows:
VB
Dim infoReader As System.IO.FileInfo

infoReader = My.Computer.FileSystem.GetFileInfo("C:\testfile.txt")

If infoReader.Length < 1000 Then
    'your code for separation

Else
    'your code for equal or bigger than 1000 bytes file

End If
 
Share this answer
 
v5
Of course it is possible. Use the FileInfo.Length[^] property for retrieving the length on the files and then copy (FileInfo.CopyTo[^]) them accordingly.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900