hey,Frnds I Have tried the Fill. Code,But the Foll. Code returns the no. of charcters of the File,But i want the File Size on Disk in KB.
Can u Plz help me out.
Imports System
Imports System.IO

Dim filelength As Long = 0

Dim objfile As New FileInfo("D:\Documents and Settings\Administrator\Desktop\URLs[1].txt")

filelength = filelength + file.Length
MsgBox(filelength)

>> filelength = filelength + file.Length
it should be objfile.length

>> filelength = filelength + file.Length
why you add filelength with file.Length?
just filelength = file.length

i suggest to make a function, so it looks neat.

Imports System.IO
...
Private Function GetFileSize(ByVal MyFilePath As String) As Long
        Dim MyFile As New FileInfo(MyFilePath)
        Dim FileSize As Long = MyFile.Length
        Return FileSize
    End Function

to call this function :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim temp As String
        temp = GetFileSize("D:\Address.txt") / 1000

        MsgBox(temp)
    End Sub

HI Frnd thx,But there are few Mistakes in UR Code.
First is that temp variable should be of Long datatype. & We divide the temp by 1024 not by 1000.
KB= 1024 bytes.

If i m wrong,point me out.

Hey one thing more i want that to calculate the File Size everytime we have to give extension such as .txt,.doc.
AS FOLL--
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim filelength As Long
filelength = GetFileSize("D:\Documents and Settings\Administrator\Desktop\Private Function SaveDetails[1].doc")
MsgBox(filelength)
End Sub

Private Function GetFileSize(ByVal MyFilePath As String) As Long
Dim MyFile As New FileInfo(MyFilePath)
Dim FileSize As Long = MyFile.Length / 1024
Return FileSize
End Function

I want that Only I change the File name & it computes the Size everytime giving the extension.......
Plz do reply back,I will be very thxful to u.

No NEED TO REPLY ANYTHING, I GOT IT......I m saying which is not possible

Well, great..
Don't forget to mark this thread solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.