FileSize - HowTo

M

mosscliffe

I get a list of filenames from a directory with the following code, but
I can not work out how to get the filesize of the filename I have just
found.

I guess it is fileinfo.length, but I can not see how to turn my
filename(string) into a statement which would give me the filesize -
the brain is very slow today. Any help gratefully appreciated.

Dim files() As String = System.IO.Directory.GetFiles(root,
patt)
dim filename as string
Dim f As String
For Each f In files
filename = System.IO.Path.GetFileName(f)
DropDownList1.Items.Add(filename)
..... GET FILESIZE OF ABOVE FILE and add to array
filesizes
Next
 
R

Ray Booysen

Hi Mosscliffe

Try this

for each f in files
dim fi as new FileInfo(f)
dim FileSize as int

FileSize = fi.Length()
next

Regards
Ray
 
M

mosscliffe

Thank you very much - all now working as envisaged. Just could not
figure it out.
 

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

Top