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

Size of the file?

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

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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
Nov 20 '05 #2

P: n/a
And how do I delete the file?

k.

"Richard Myers" <ri*********************@basd.co.nz> wrote in message
news:e9**************@tk2msftngp13.phx.gbl...
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


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #3

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

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #4

P: n/a
file.delete("C:\???????????")
-----Original Message-----
And how do I delete the file?

k.

"Richard Myers" <ri*********************@basd.co.nz> wrote in messagenews:e9**************@tk2msftngp13.phx.gbl...
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


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------

http://www.usenet.com
.

Nov 20 '05 #5

P: n/a
I found this amazing site which explains a lot on How To Do Basic File I/O
in Visual Basic .NET
http://support.microsoft.com/default...b;EN-US;304427

They also mentioned how to delete file on this site:
http://aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=206
Example for deleting:
' VB.NET
File.Delete("C:\MyFiles\SomeFile.xml")
So thanks for everything. I hope this helps other people as well.

k.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #6

P: n/a
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
///
Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.