Renci.SshNet.Sftp.SftpUploadAsyncResult.Update C# (CSharp) Method

Update() private method

Updates asynchronous operation status information.
private Update ( ulong uploadedBytes ) : void
uploadedBytes ulong Number of uploaded bytes.
return void
        internal void Update(ulong uploadedBytes)
        {
            UploadedBytes = uploadedBytes;
        }
    }

Usage Example

コード例 #1
1
ファイル: SftpClient.cs プロジェクト: leocheang422/win-sshfs
        private void InternalUploadFile(Stream input, string path, SftpUploadAsyncResult asynchResult, Flags flags)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            if (path.IsNullOrWhiteSpace())
                throw new ArgumentException("path");

            //  Ensure that connection is established.
            this.EnsureConnection();

            var fullPath = this._sftpSession.GetCanonicalPath(path);

            var handle = this._sftpSession.RequestOpen(fullPath, flags);

            ulong offset = 0;

            var buffer = new byte[this.BufferSize];

            var uploadCompleted = false;

            do
            {
                var bytesRead = input.Read(buffer, 0, buffer.Length);

                if (bytesRead < this.BufferSize)
                {
                    var data = new byte[bytesRead];
                    Buffer.BlockCopy(buffer, 0, data, 0, bytesRead); 
                    using (var wait = new AutoResetEvent(false))
                    {
                        this._sftpSession.RequestWrite(handle, offset, data, wait);
                    }
                    uploadCompleted = true;
                }
                else
                {
                    this._sftpSession.RequestWrite(handle, offset, buffer, null);
                }

                offset += (uint)bytesRead;

                //  Call callback to report number of bytes read
                if (asynchResult != null)
                {
                    asynchResult.Update(offset);
                }

            } while (!uploadCompleted);

            this._sftpSession.RequestClose(handle);
        }
All Usage Examples Of Renci.SshNet.Sftp.SftpUploadAsyncResult::Update
SftpUploadAsyncResult