Link to home
Start Free TrialLog in
Avatar of vmandem
vmandem

asked on

How can I find the size of a file from the programme

I run a programme and it creates a file and I'm calling other procedures based on the file creation. I know how to check whether the file is created or not  BUT I WANT TO KNOW THE FILE SIZE. IF THE FILE SIZE IS 1KB I DON'T WANT TO CALL ANY PROCEDURES FURTHER OTHERWISE I WANT TO. How to determine the file size which is sitting in one of my directories.

Thanks
vm
ASKER CERTIFIED SOLUTION
Avatar of S-Twilley
S-Twilley

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of S-Twilley
S-Twilley

you can also use the FileLen function

Dim fLength As Integer = FileLen(myFileName)
Avatar of Bob Learned
Imports System.IO

Public Class IO_Library

  Public Shared Function FileSize(ByVal path As String) As Integer

    Dim info As New FileInfo(path)

    Return info.Length

  End Function 'FileSize'

End Class 'IO_Library'


Usage:
Dim size As Integer = IO_Library.FileSize(path)

Bob
Ooh, too slow :(

Bob
I know the feeling... went to sleep for a few hours and all the good (well.. the questions I can answer) have all passed me by!

Dim filename as string
Dim fi As IO.FileInfo

filename="YourFileName"
fi=new IO.FileInfo(filename)
MessageBox.Show(fi.Length.ToString)


fi.Length contains the file size  in bytes.

Hope this help
"Another rides the bus, and another one's on, and another one's on..."  :)

Bob
I think there's an echo on this thread :P
Avatar of vmandem

ASKER

I thank every one for overwhelming responses. I Love EE.

Thanks Again.
vm