Back to product page

GetFile method


Downloads file from the server.

Type

Void

Syntax

  • C#
  • VB.NET
public Void GetFile();

public Void GetFile(Stream ToStream);
The GetFile(ToStream) syntax has these parts:
ToStreamWritable stream where contents of the file will be stored.

public Void GetFile(String RemoteFile);
The GetFile(RemoteFile) syntax has these parts:
RemoteFilePath to the file on the server.

public Void GetFile(Stream ToStream, String RemoteFile);
The GetFile(ToStream,RemoteFile) syntax has these parts:
ToStreamWritable stream where contents of the file will be stored.
RemoteFilePath to the file on the server.

public Void GetFile(String LocalPath, String RemoteFile);
The GetFile(LocalPath,RemoteFile) syntax has these parts:
LocalPathLocal path of filename where file will be saved.
RemoteFilePath to the file on the server.

public Sub GetFile()

public Sub GetFile(ByVal ToStream As Stream)
The GetFile(ToStream) syntax has these parts:
ToStreamWritable stream where contents of the file will be stored.

public Sub GetFile(ByVal RemoteFile As String)
The GetFile(RemoteFile) syntax has these parts:
RemoteFilePath to the file on the server.

public Sub GetFile(ByVal ToStream As Stream, ByVal RemoteFile As String)
The GetFile(ToStream,RemoteFile) syntax has these parts:
ToStreamWritable stream where contents of the file will be stored.
RemoteFilePath to the file on the server.

public Sub GetFile(ByVal LocalPath As String, ByVal RemoteFile As String)
The GetFile(LocalPath,RemoteFile) syntax has these parts:
LocalPathLocal path of filename where file will be saved.
RemoteFilePath to the file on the server.

Remarks

GetFile method will initiate copying of file residing on remote server to the local computer. During the transfer, Progress event will be fired several times, depending on your network speed and length of the file.
When the copying is completed, Done event will be fired.

If an error occurs during transfer, Done event will be fired immediately containing ErrorCode and description for the error, and transfer will be aborted. If you want to continue it later, or try to re-receive the file, initiate GetFile method again (immediately or after reconnecting, depends on error that occurred). You may also use Resume property to resume transferring from the position where the error occurred.

This method can be initiated only when State property is set to Connected. You cannot receive file if wodSFTP.NET is busy doing something else.

Although RemoteFile argument MUST contain full path including filename of the file you wish to receive, LocalPath can omit filename. For instance, you can set
LocalPath = "C:\Temp"

in which case wodSFTP.NET will automatically copy it with the same name as it is on remote server. If you wish to specify that is copied with some other name, you have to include it in LocalPath argument.

If you don't specify LocalPath or RemoteFile argument, wodSFTP.NET will use values set in LocalPath and RemotePath properties.

No wildcards can be used for RemotePath argument. RFC protocol specification for SFTP does not allow them.

Platforms

Windows