Size of the file?

  • Thread starter Thread starter Krakatioison
  • Start date Start date
K

Krakatioison

Does anyone know how to write this condition?

Basically, I need to find the size of particular .jpg file and if it's
smaller than 100kb I want to delete it.

Please, let me know. Very very appreciated.

K.
 
And how do I delete the file?

k.



Richard Myers said:
File size is a property of an fileInfo object. Feed the jpg path into the
FileInfo constructor to create a fileinfo object and then check this
property.

hth
Richard
 
File size is a property of an fileInfo object. Feed the jpg path into the
FileInfo constructor to create a fileinfo object and then check this
property.

hth
Richard
 
So I would do something like this?


Dim FileProps As FileInfo = New FileInfo(test.jpg")
With Me.ListBox1.Items
.Clear()
.Add("File Name = " & FileProps.FullName)
.Add("Size = " & FileProps.Length)
End With
FileProps = Nothing

When I found that file is less than 100kb... how do I delete it?

k.
 
Kraktioison,

An alternative (Not tested)

I hope this helps?

Cor

\\\\
Dim di As New IO.DirectoryInfo("c:\mydir")
Dim fiArr() As IO.FileInfo = di.GetFiles
Dim fi As IO.FileInfo
For Each f In fiArr
if fi.Lenth < 100000 AndAlso fi.extention = "jpg" then
fi.delete
end if
Next f
///
 
Back
Top