public string GetGitHubAccountDirectoryPath(string solutionFilePath) { var solutionDirectoryPath = PathUtilities.GetDirectoryPath(solutionFilePath); var sourceDirectoryPath = PathUtilities.GetParentDirectoryPath(solutionFilePath); var repositoryDirectoryPath = PathUtilities.GetParentDirectoryPath(sourceDirectoryPath); var gitHubAccountDirectoryPath = PathUtilities.GetParentDirectoryPath(repositoryDirectoryPath); return(gitHubAccountDirectoryPath); }
public string GetSolutionFilePath(string currentExecutableFilePath, string solutionFileName) { var binDebugNetCoreAppDirectoryPath = PathUtilities.GetDirectoryPath(currentExecutableFilePath); var binDebugDirectoryPath = PathUtilities.GetParentDirectoryPath(binDebugNetCoreAppDirectoryPath); var binDirectoryPath = PathUtilities.GetParentDirectoryPath(binDebugDirectoryPath); var projectDirectoryPath = PathUtilities.GetParentDirectoryPath(binDirectoryPath); var solutionDirectoryPath = PathUtilities.GetParentDirectoryPath(projectDirectoryPath); var solutionFilePath = PathUtilities.Combine(solutionDirectoryPath, solutionFileName); return(solutionFilePath); }
/// <summary> /// Creates a directory, creating all required intermediate directories. /// Ok if the directory already exists (idempotent) like <see cref="CreateDirectoryOkIfExists(SftpClient, string)"/>. /// </summary> /// <remarks> /// The <see cref="Renci.SshNet.SftpClient.CreateDirectory(string)"/> method will not make intermediate directories for nested directories. For example, if A exists, but B does not, a call to create C such that /A/B/C will fail with exception: /// Renci.SshNet.Common.SftpPathNotFoundException: 'No such file' /// </remarks> public static void CreateDirectoryOkIfIntermediatesAndExists(this SftpClient sftpClient, string directoryPath) { // The SftpClient.CreateDirectory() call will not make intermediate directories as required for a path. // This work-around walks up the directory tree until a parent directory exists, and makes intermediate directories as required. var parentDirectoryPath = PathUtilities.GetParentDirectoryPath(directoryPath); if (!sftpClient.Exists(parentDirectoryPath)) { sftpClient.CreateDirectoryOkIfIntermediatesAndExists(parentDirectoryPath); } sftpClient.CreateDirectoryOkIfExists(directoryPath); }