SftpFile
Represents SFTP file information.
            
                using Renci.SshNet.Common;
using System;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
namespace Renci.SshNet.Sftp
{
    public sealed class SftpFile : ISftpFile
    {
        private readonly ISftpSession _sftpSession;
        public SftpFileAttributes Attributes { get; set; }
        public string FullName { get; set; }
        public string Name { get; set; }
        public DateTime LastAccessTime {
            get {
                return Attributes.LastAccessTime;
            }
            set {
                Attributes.LastAccessTime = value;
            }
        }
        public DateTime LastWriteTime {
            get {
                return Attributes.LastWriteTime;
            }
            set {
                Attributes.LastWriteTime = value;
            }
        }
        public DateTime LastAccessTimeUtc {
            get {
                return Attributes.LastAccessTimeUtc;
            }
            set {
                Attributes.LastAccessTimeUtc = value;
            }
        }
        public DateTime LastWriteTimeUtc {
            get {
                return Attributes.LastWriteTimeUtc;
            }
            set {
                Attributes.LastWriteTimeUtc = value;
            }
        }
        public long Length => Attributes.Size;
        public int UserId {
            get {
                return Attributes.UserId;
            }
            set {
                Attributes.UserId = value;
            }
        }
        public int GroupId {
            get {
                return Attributes.GroupId;
            }
            set {
                Attributes.GroupId = value;
            }
        }
        public bool IsSocket => Attributes.IsSocket;
        public bool IsSymbolicLink => Attributes.IsSymbolicLink;
        public bool IsRegularFile => Attributes.IsRegularFile;
        public bool IsBlockDevice => Attributes.IsBlockDevice;
        public bool IsDirectory => Attributes.IsDirectory;
        public bool IsCharacterDevice => Attributes.IsCharacterDevice;
        public bool IsNamedPipe => Attributes.IsNamedPipe;
        public bool OwnerCanRead {
            get {
                return Attributes.OwnerCanRead;
            }
            set {
                Attributes.OwnerCanRead = value;
            }
        }
        public bool OwnerCanWrite {
            get {
                return Attributes.OwnerCanWrite;
            }
            set {
                Attributes.OwnerCanWrite = value;
            }
        }
        public bool OwnerCanExecute {
            get {
                return Attributes.OwnerCanExecute;
            }
            set {
                Attributes.OwnerCanExecute = value;
            }
        }
        public bool GroupCanRead {
            get {
                return Attributes.GroupCanRead;
            }
            set {
                Attributes.GroupCanRead = value;
            }
        }
        public bool GroupCanWrite {
            get {
                return Attributes.GroupCanWrite;
            }
            set {
                Attributes.GroupCanWrite = value;
            }
        }
        public bool GroupCanExecute {
            get {
                return Attributes.GroupCanExecute;
            }
            set {
                Attributes.GroupCanExecute = value;
            }
        }
        public bool OthersCanRead {
            get {
                return Attributes.OthersCanRead;
            }
            set {
                Attributes.OthersCanRead = value;
            }
        }
        public bool OthersCanWrite {
            get {
                return Attributes.OthersCanWrite;
            }
            set {
                Attributes.OthersCanWrite = value;
            }
        }
        public bool OthersCanExecute {
            get {
                return Attributes.OthersCanExecute;
            }
            set {
                Attributes.OthersCanExecute = value;
            }
        }
        internal SftpFile(ISftpSession sftpSession, string fullName, SftpFileAttributes attributes)
        {
            if (sftpSession == null)
                throw new SshConnectionException("Client not connected.");
            ThrowHelper.ThrowIfNull(attributes, "attributes");
            ThrowHelper.ThrowIfNull(fullName, "fullName");
            _sftpSession = sftpSession;
            Attributes = attributes;
            Name = fullName.Substring(fullName.LastIndexOf('/') + 1);
            FullName = fullName;
        }
        public void SetPermissions(short mode)
        {
            Attributes.SetPermissions(mode);
            UpdateStatus();
        }
        public void Delete()
        {
            if (IsDirectory)
                _sftpSession.RequestRmDir(FullName);
            else
                _sftpSession.RequestRemove(FullName);
        }
        public Task DeleteAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            if (!IsDirectory)
                return _sftpSession.RequestRemoveAsync(FullName, cancellationToken);
            return _sftpSession.RequestRmDirAsync(FullName, cancellationToken);
        }
        public void MoveTo(string destFileName)
        {
            ThrowHelper.ThrowIfNull(destFileName, "destFileName");
            _sftpSession.RequestRename(FullName, destFileName);
            string canonicalPath = _sftpSession.GetCanonicalPath(destFileName);
            Name = canonicalPath.Substring(canonicalPath.LastIndexOf('/') + 1);
            FullName = canonicalPath;
        }
        public void UpdateStatus()
        {
            _sftpSession.RequestSetStat(FullName, Attributes);
        }
        public override string ToString()
        {
            CultureInfo currentCulture = CultureInfo.CurrentCulture;
            <>y__InlineArray6<object> buffer = default(<>y__InlineArray6<object>);
            global::<PrivateImplementationDetails>.InlineArrayElementRef<<>y__InlineArray6<object>, object>(ref buffer, 0) = Name;
            global::<PrivateImplementationDetails>.InlineArrayElementRef<<>y__InlineArray6<object>, object>(ref buffer, 1) = Length;
            global::<PrivateImplementationDetails>.InlineArrayElementRef<<>y__InlineArray6<object>, object>(ref buffer, 2) = UserId;
            global::<PrivateImplementationDetails>.InlineArrayElementRef<<>y__InlineArray6<object>, object>(ref buffer, 3) = GroupId;
            global::<PrivateImplementationDetails>.InlineArrayElementRef<<>y__InlineArray6<object>, object>(ref buffer, 4) = LastAccessTime;
            global::<PrivateImplementationDetails>.InlineArrayElementRef<<>y__InlineArray6<object>, object>(ref buffer, 5) = LastWriteTime;
            return string.Format(currentCulture, "Name {0}, Length {1}, User ID {2}, Group ID {3}, Accessed {4}, Modified {5}", global::<PrivateImplementationDetails>.InlineArrayAsReadOnlySpan<<>y__InlineArray6<object>, object>(ref buffer, 6));
        }
    }
}