Renci.SshNet.SftpClient.RenameFile C# (CSharp) Method

RenameFile() public method

Renames remote file from old path to new path.
is null. -or- or is null. Client is not connected. Permission to rename the file was denied by the remote host. -or- A SSH command was denied by the server. A SSH error where is the message from the remote host. The method was called after the client was disposed.
public RenameFile ( string oldPath, string newPath ) : void
oldPath string Path to the old file location.
newPath string Path to the new file location.
return void
        public void RenameFile(string oldPath, string newPath)
        {
            RenameFile(oldPath, newPath, false);
        }

Same methods

SftpClient::RenameFile ( string oldPath, string newPath, bool isPosix ) : void

Usage Example

Beispiel #1
0
        public override async Task Rename(string oldname, string newname)
        {
            if (Exists(newname))
            {
                Log.Write(l.Info, $"Replacing remote file: [{newname}]");
                await Remove(newname);
            }

            var caughtException = default(Exception);
            await Task.Run(() =>
            {
                try
                {
                    _sftpc.RenameFile(oldname, newname);
                }
                catch (Exception ex)
                {
                    ex.LogException();
                    caughtException = ex;
                }
            });

            if (caughtException != default(Exception))
            {
                throw caughtException;
            }
        }
All Usage Examples Of Renci.SshNet.SftpClient::RenameFile