Resume Uploads and Downloads Using the FTP Component
The StartByte property specifies an offset that determines the starting point for all uploads and downloads. It controls where data transmission begins, allowing file transfers to resume from a specific position instead of starting over.
This property contains a zero-based index for both RemoteFile and LocalFile that determines the point from which data transmission begins. Once set, the StartByte index is used for all future downloads/uploads. The property must be reset to "0" for normal downloads/uploads. The code below demonstrates how this property can be used to resume an upload.
Note: FileSize is an action property. When queried, it will ask the server for the size of the file specified by the RemoteFile property.
C#
ftp.LocalFile = @"C:\LocalFile.txt";
ftp.RemoteFile = "RemoteFile.txt";
ftp.StartByte = ftp.FileSize.ToString();
ftp.Upload();
ftp.StartByte = "0";
Java
ftp.setLocalFile("C:\\LocalFile.txt");
ftp.setRemoteFile("RemoteFile.txt");
ftp.setStartByte(String.valueOf(ftp.getFileSize()));
ftp.upload();
ftp.setStartByte("0");
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.