NET FTP Library
GetFileSize(String) Method
Example 






KellermanSoftware.NetFtpLibrary Namespace > FTP Class : GetFileSize(String) Method
Name of file in the current directory
Gets the file size of a remote file in bytes.
Syntax
'Declaration
 
Public Function GetFileSize( _
   ByVal fileName As System.String _
) As System.Long
'Usage
 
Dim instance As FTP
Dim fileName As System.String
Dim value As System.Long
 
value = instance.GetFileSize(fileName)
public System.long GetFileSize( 
   System.string fileName
)
public function GetFileSize( 
    fileName: System.String
): System.Int64; 
public function GetFileSize( 
   fileName : System.String
) : System.long;
public: System.long GetFileSize( 
   System.string* fileName
) 
public:
System.int64 GetFileSize( 
   System.String^ fileName
) 

Parameters

fileName
Name of file in the current directory

Return Value

The file size, or -1 on failure
Example
FTP ftp = new FTP(); //Trial Mode
//FTP ftp = new FTP("place user name here", "place license key here");
 
// set the name of the FTP server( its URL )
ftp.HostAddress = "ftp.fsz.bme.hu"; // a hungarian university. change this to your ftp server
ftp.UserName = "anonymous"; // replace with your user name
ftp.Password = "user@mail.com"; // replace with your password
 
//Gets the file size of a remote file 
long size = ftp.GetFileSize("a.txt");
 
System.Console.WriteLine("a.txt`s size is {0}", size);
Dim ftp As FTP = New FTP() 'Trial Mode
'FTP ftp = new FTP("place user name here", "place license key here");
 
' set the name of the FTP server( its URL )
ftp.HostAddress = "ftp.fsz.bme.hu" ' a hungarian university. change this to your ftp server
ftp.UserName = "anonymous" ' replace with your user name
ftp.Password = "user@mail.com" ' replace with your password
 
'Gets the file size of a remote file
Dim size As Long = ftp.GetFileSize("a.txt")
 
System.Console.WriteLine("a.txt`s size is {0}", size)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

FTP Class
FTP Members