SocketTools .NET Edition

FtpClient.GetFileSize Method (String, Int32)

Returns the size of the specified file on the remote server.

[Visual Basic]
Overloads Public Function GetFileSize( _
   ByVal remoteFile As String, _
   ByRef fileSize As Integer _
) As Boolean
[C#]
public bool GetFileSize(
   string remoteFile,
   ref int fileSize
);

Parameters

remoteFile
A string that specifies the name of the file on the server. The filename cannot contain any wildcard characters and must follow the naming conventions of the operating system the server is hosted on.
fileSize
A long integer value which is passed by reference and will specify the size of the file on the server when the method returns.

Return Value

This method returns a boolean value. If the method succeeds, the return value is true. If the method fails, the return value is false. To get extended error information, check the value of the LastError property.

Remarks

This method uses the SIZE command to determine the length of the specified file. Not all servers implement this command, in which case the method will fail. You can use the Features property to determine what features are available and/or enabled on the server.

Note that if the file on the server is a text file, it is possible that the value returned by this method will not match the size of the file when it is downloaded to the local system. This is because different operating systems use different sequences of characters to mark the end of a line of text, and when a file is transferred in text mode, the end of line character sequence is automatically converted to a carriage return-linefeed, which is the convention used by the Windows platform.

See Also

FtpClient Class | SocketTools Namespace | FtpClient.GetFileSize Overload List