Gets the size of the specified remote file.
public override long GetFileLength(
string filePath
)
Public Overrides Function GetFileLength( _
ByVal filePath As String _
) As Long
public:
long GetFileLength(
String^ filePath
); override
Parameters
- filePath
- The path of the remote file. This cannot be a directory.
Return Value
The size of the specified file in bytes.
Remarks
Represents FTP SIZE command.
The SIZE command was not defined by the original RFC, but it has been widely supported for a number of years.
Shows how to use GetFileLength method to get length of a file on an FTP server.
using System;
using ComponentPro.Net;
...
// Create a new class instance.
Ftp client = new Ftp();
// Connect to the FTP server.
client.Connect("localhost");
// Authenticate.
client.Authenticate("test", "test");
// ...
// Get size in bytes of the remote file '/test.dat'.
long length = client.GetFileLength("/test.dat");
Console.WriteLine("'/test.dat' file length is: {0} bytes", length);
// ...
// Disconnect.
client.Disconnect();
Imports ComponentPro.Net
...
' Create a new class instance.
Dim client As New Ftp()
' Connect to the FTP server.
client.Connect("localhost")
' Authenticate.
client.Authenticate("test", "test")
' ...
' Get size in bytes of the remote file '/test.dat'.
Dim length As Long = client.GetFileLength("/test.dat")
Console.WriteLine("'/test.dat' file length is: {0} bytes", length)
' ...
' Disconnect.
client.Disconnect()