Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Index of Chilkat Blog Posts

December 11, 2007

How to Get the Size of a Large File (> 4 GB) on an FTP Server (64-bit integer)

The Chilkat FTP2 component provides a GetSizeStr method to retrieve the size of a file as a string. This allows the size to be converted to a 64-bit integer in any programming language. Here is an example in VB.NET.

The GetSizeStr returns the size of the Nth file in the directory (matching the ListPattern). If the ListPattern is set to the exact filename without wildcard characters, then only one file will match (if it exists). Therefore, GetSizeStr(0) returns the size of the file specified by ListPattern:

        '  Set the current remote directory to where the file is located:
        success = ftp.ChangeRemoteDir("/temp")
        If (success <> True) Then
            MsgBox(ftp.LastErrorText)
            Exit Sub
        End If
	
        '  Set the ListPattern to the exact filename.
        ftp.ListPattern = "hamlet.xml"
        If (ftp.NumFilesAndDirs = 1) Then
            ' If it exists, NumFilesAndDirs = 1
            ' Get the file size as an integer string.
            Dim fileSizeStr As String
            fileSizeStr = ftp.GetSizeStr(0)
	
            ' ULong is a 64-bit integer in VB.NET
            Dim fileSize64 As ULong
            fileSize64 = System.Convert.ToUInt64(fileSizeStr)
	
            MsgBox(fileSize64)
        End If


Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.