FileSize - HowTo

  • Thread starter Thread starter mosscliffe
  • Start date Start date
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
 
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
 
Back
Top