Results 1 to 2 of 2

Thread: Check File SIze

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Check File SIze

    I have written some code which uploads a file.

    Before I upload the file I would like to check on the file size. If its below a certain limit I want to upload it else present the user with an error message.

    Any Ideas ?

    Parksie

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    First I didn't check the code but it looks it should work .
    VB Code:
    1. Private Sub CheckFileSiz(ByVal File As String)
    2.  
    3.         'Parameters : File = provide full path
    4.  
    5.         Dim Finfo As New IO.FileInfo(File)
    6.         Dim Siz As Integer
    7.  
    8.         If IO.File.Exists(File) Then
    9.             Siz = Finfo.Length
    10.         Else
    11.             Exit Sub
    12.         End If
    13.  
    14.         Select Case Siz
    15.  
    16.             Case 100 '100k
    17.                 'Do this
    18.  
    19.             Case 200 '200 k
    20.                 'Do this
    21.  
    22.             Case 300 '300k
    23.                 'Do this
    24.  
    25.             Case Is <= 500 'k
    26.                 'Do this
    27.  
    28.             Case Is <= 1000 'k
    29.                 'Do this
    30.  
    31.         End Select
    32.  
    33.     End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width