コード例 #1
0
        private static string CreateRemoteDirectory(SftpClient sftp, string fileName, string remoteDirectoryPath)
        {
            if (!string.IsNullOrWhiteSpace(remoteDirectoryPath))
            {
                // auto-connect
                if (sftp.IsConnected == false)
                {
                    sftp.Connect();
                }

                var exists = sftp.DoesRemoteFileExist(remoteDirectoryPath);

                if (!exists)
                {
                    sftp.CreateDirectory(remoteDirectoryPath);
                }

                return(Path.Combine(remoteDirectoryPath, fileName));
            }
            return(fileName);
        }