Dart.Ftp Namespace > Ftp Class > Put Method : Put(Stream,String,Int64,StoreType) Method |
Public Overloads Function Put( _ ByVal localSource As Stream, _ ByVal remotePath As String, _ ByVal remoteOffset As Long, _ ByVal storeType As StoreType _ ) As CopyResult
Dim instance As Ftp Dim localSource As Stream Dim remotePath As String Dim remoteOffset As Long Dim storeType As StoreType Dim value As CopyResult value = instance.Put(localSource, remotePath, remoteOffset, storeType)
public CopyResult Put( Stream localSource, string remotePath, long remoteOffset, StoreType storeType )
public: CopyResult^ Put( Stream^ localSource, String^ remotePath, int64 remoteOffset, StoreType storeType )
The source Stream is not closed.
DataIsBusy returns true while this method executes.
Characters specified in the remote path are sent to the server unmodified. If the path contains characters that are invalid for the server host filesystem, it may cause the operation to fail with an FtpProtocolException.
/// <summary> /// Resumes a Put operation /// </summary> /// <param name="myFtp">A connected and authenticated Ftp instance</param> /// <param name="localPath">Path to the local file</param> /// <param name="remotePath">An absolute or relative path to the file on the server</param> /// <returns>The CopyResult of the operation</returns> public CopyResult RestartPut(Ftp myFtp, string localPath, string remotePath) { //Check that the server advertises/supports features required to resume a Put if (!myFtp.Features.Size || !myFtp.Features.Restart) throw new Exception("Server doesn't support features required to restart a Put"); //Ensure that the Ftp object is in binary/image transfer mode myFtp.SetType(FileType.Image); //Get the size of the remote file long offset = myFtp.GetSize(remotePath); using (FileStream fs = File.OpenRead(localPath)) { //Set the stream to the correct position fs.Position = offset; //Resume the transfer, and (optionally) return the result return myFtp.Put(fs, remotePath, offset, StoreType.Replace); } }
''' <summary> ''' Resumes a Put operation ''' </summary> ''' <param name="myFtp">A connected and authenticated Ftp instance</param> ''' <param name="localPath">Path to the local file</param> ''' <param name="remotePath">An absolute or relative path to the file on the server</param> ''' <returns>The CopyResult of the operation</returns> Public Function RestartPut(ByVal myFtp As Ftp, ByVal localPath As String, ByVal remotePath As String) As CopyResult 'Check that the server advertises/supports features required to resume a Put If (Not myFtp.Features.Size) OrElse (Not myFtp.Features.Restart) Then Throw New Exception("Server doesn't support features required to restart a Put") End If 'Ensure that the Ftp object is in binary/image transfer mode myFtp.SetType(FileType.Image) 'Get the size of the remote file Dim offset As Long = myFtp.GetSize(remotePath) Using fs As FileStream = File.OpenRead(localPath) 'Set the stream to the correct position fs.Position = offset 'Resume the transfer, and (optionally) return the result Return myFtp.Put(fs, remotePath, offset, StoreType.Replace) End Using End Function