FileRename Event

Fires when a client wants to rename a file.

Syntax

public event OnFileRenameHandler OnFileRename;

public delegate void OnFileRenameHandler(object sender, SftpserverFileRenameEventArgs e);

public class SftpserverFileRenameEventArgs : EventArgs {
  public string ConnectionId { get; }
  public string User { get; }
  public string Path { get; }
  public string NewPath { get; }
  public int Flags { get; }
  public bool BeforeExec { get; }
  public int StatusCode { get; set; }
}
Public Event OnFileRename As OnFileRenameHandler

Public Delegate Sub OnFileRenameHandler(sender As Object, e As SftpserverFileRenameEventArgs)

Public Class SftpserverFileRenameEventArgs Inherits EventArgs
  Public ReadOnly Property ConnectionId As String
  Public ReadOnly Property User As String
  Public ReadOnly Property Path As String
  Public ReadOnly Property NewPath As String
  Public ReadOnly Property Flags As Integer
  Public ReadOnly Property BeforeExec As Boolean
  Public Property StatusCode As Integer
End Class

Remarks

The Path parameter will specify the file to rename and NewPath will specify the new name. The Flags parameter will be a bit mask of the values SSH_FXF_RENAME_OVERWRITE (0x00000001), SSH_FXF_RENAME_ATOMIC (0x00000002) and SSH_FXF_RENAME_NATIVE (0x00000004)

This event is fired both before and after the file is renamed. The BeforeExec parameter is True before the operation has been executed and False otherwise. Handling this event before execution of the operation provides an opportunity to add custom logic that may prevent or deny the operation. Handling this event after execution of the operation provides an opportunity to report any errors that may have occurred during the operation.

Valid status codes are:

  • SSH_FX_OK 0
  • SSH_FX_EOF 1
  • SSH_FX_NO_SUCH_FILE 2
  • SSH_FX_PERMISSION_DENIED 3
  • SSH_FX_FAILURE 4
  • SSH_FX_BAD_MESSAGE 5
  • SSH_FX_NO_CONNECTION 6
  • SSH_FX_CONNECTION_LOST 7
  • SSH_FX_OP_UNSUPPORTED 8
  • SSH_FX_INVALID_HANDLE 9
  • SSH_FX_NO_SUCH_PATH 10
  • SSH_FX_FILE_ALREADY_EXISTS 11
  • SSH_FX_WRITE_PROTECT 12
  • SSH_FX_NO_MEDIA 13
  • SSH_FX_NO_SPACE_ON_FILESYSTEM 14
  • SSH_FX_QUOTA_EXCEEDED 15
  • SSH_FX_UNKNOWN_PRINCIPAL 16
  • SSH_FX_LOCK_CONFLICT 17
  • SSH_FX_DIR_NOT_EMPTY 18
  • SSH_FX_NOT_A_DIRECTORY 19
  • SSH_FX_INVALID_FILENAME 20
  • SSH_FX_LINK_LOOP 21
  • SSH_FX_CANNOT_DELETE 22
  • SSH_FX_INVALID_PARAMETER 23
  • SSH_FX_FILE_IS_A_DIRECTORY 24
  • SSH_FX_BYTE_RANGE_LOCK_CONFLICT 25
  • SSH_FX_BYTE_RANGE_LOCK_REFUSED 26
  • SSH_FX_DELETE_PENDING 27
  • SSH_FX_FILE_CORRUPT 28
  • SSH_FX_OWNER_INVALID 29
  • SSH_FX_GROUP_INVALID 30
  • SSH_FX_NO_MATCHING_BYTE_RANGE_LOCK 31

Copyright (c) 2023 /n software inc. - All rights reserved.
IPWorks SSH 2020 .NET Edition - Version 20.0 [Build 8501]