public RenameFile ( string oldPath, string newPath, bool isPosix ) : void | ||
oldPath | string | Path to the old file location. |
newPath | string | Path to the new file location. |
isPosix | bool | if set to |
Résultat | void |
public void RenameFile(string oldPath, string newPath, bool isPosix)
{
CheckDisposed();
if (oldPath == null)
throw new ArgumentNullException("oldPath");
if (newPath == null)
throw new ArgumentNullException("newPath");
if (_sftpSession == null)
throw new SshConnectionException("Client not connected.");
var oldFullPath = _sftpSession.GetCanonicalPath(oldPath);
var newFullPath = _sftpSession.GetCanonicalPath(newPath);
if (isPosix)
{
_sftpSession.RequestPosixRename(oldFullPath, newFullPath);
}
else
{
_sftpSession.RequestRename(oldFullPath, newFullPath);
}
}
SftpClient::RenameFile ( string oldPath, string newPath ) : void |
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; } }