NET SFTP Library
GetFileSize(String) Method
Example 






KellermanSoftware.NetSFtpLibrary Namespace > SFTP 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 SFTP
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
SFTP sftp = new SFTP(); //Trial Mode
            //SFTP sftp = new SFTP("place user name here", "place license key here");
             
            // set the name of the SSH server( its URL )
            sftp.HostAddress = "some.sftp.server.com"; // replace with your SFTP server
            sftp.UserName  = "anonymous"; // replace with your user name
            sftp.Password = "user@mail.com"; // replace with your password
             
            //Gets the file size of a remote file 
            long size = sftp.GetFileSize("a.txt");
             
            System.Console.WriteLine("a.txt`s size is {0}", size);
Dim sftp As SFTP = New SFTP() 'Trial Mode
            'Dim sftp As SFTP = New SFTP("place user name here", "place license key here");
             
            ' set the name of the SSH server( its URL )
            sftp.HostAddress = "some.sftp.server.com" ' replace with your SFTP server
            sftp.UserName  = "anonymous" ' replace with your user name
            sftp.Password = "user@mail.com" ' replace with your password
             
            'Gets the file size of a remote file
            Dim size As Long = sftp.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

SFTP Class
SFTP Members