473,473 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Size of the file?

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
6 938
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Arnold | last post by:
Is using fseek and ftell a reliable method of getting the file size on a binary file? I thought I remember reading somewhere it wasn't... If not what would be the "right" and portable method to...
6
by: Andrew Clark | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** Hello all, I recall several threads over the years about how reading file size cannot be done consistantly or portably, but I...
8
by: Dave | last post by:
I am serialising an object to a memory mapped file (using the CreateFileMapping and MapViewOfFile p/invoke calls). These need to know the maximum size of the "file". I can put in a "good guess" ie...
8
by: Ron | last post by:
Hi all, How do I determine the size of the tables I'm using? I looked under properties and it's not there. The book I just browsed said table is limited to 1GB. How do I find out what size my...
5
by: Jefferis NoSpamme | last post by:
Hi all, I'm trying to limit the file size of an image submission and I keep running into various problems. I've got most of it working, but I'm stumped and I have a basic question as to WHY this...
12
by: Phil Z. | last post by:
After migrating an ASP.NET 1.1 application to 2.0 we were getting "Cannot access a closed file" errors when uploading. I found a number of post on the subject and have since moved from using an...
4
by: Doug | last post by:
Hi, It looks like the only way to get a size of a file within csharp is to use FileInfo and the Length property. However that only returns the number of bytes in the file which is translating...
1
by: chrisj | last post by:
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully. In this modified version there are two groups that use this upload script. Members of one...
20
by: Ashit Vora | last post by:
Hi, I 'm new to C programming and 'm stuck somewhere. I want to find the size of a file. I couldn't find a proper way of doing it. What I was planning to do is... Open the requested file,...
18
by: MisterE | last post by:
I hear that this isn't always valid: FILE *in; long size; in = fopen("foo.bar","rb"); fseek(in,0,SEEK_END); size = ftell(in); fseek(in,0,SEEK_SET); then fread size many bytes into memory.
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.