public void Exec(params string[] args) { if (args.Length > 0) { string fullPath = Path.Combine(Directory.GetCurrentDirectory(), args[0]); if (Directory.Exists(fullPath)) { ShellEnvironment.WriteErrorLine("Specified directory already exists"); } else { try { Directory.CreateDirectory(fullPath); } catch (Exception ex) { ShellEnvironment.WriteErrorLine($"Could not create directory: {ex.Message}"); } } } }
public void Exec(params string[] args) { if (args.Length < 1) { ShellEnvironment.WriteNormalLine(Directory.GetCurrentDirectory()); } else { string resolvedPathName = Path.GetFullPath(args[0]); if (!resolvedPathName.EndsWith(Path.DirectorySeparatorChar.ToString())) //Add a / on if we didn't do one. { resolvedPathName += Path.DirectorySeparatorChar; } try { Directory.SetCurrentDirectory(resolvedPathName); } catch (Exception ex) { ShellEnvironment.WriteErrorLine($"Could not set directory: {ex.Message}"); } } }