Calculate File Size on Disk in KB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mansi sharma
    New Member
    • Mar 2008
    • 22

    Calculate File Size on Disk in KB

    Hey Frnds to calculate the File Size everytime we have to give extension such as .txt,.doc.
    AS FOLL--
    Code:
     
    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.
    Last edited by DrBunchman; Jun 23 '08, 03:05 PM. Reason: Added code tags - note the # button
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    You appear to already have a function to give you the file size in KB.
    What is the problem?

    Comment

    Working...