Ejemplo n.º 1
0
        private static bool HandleChangeDriveCommand(string command, ICommandAccess commandAccess)
        {
            command = command.Trim();

            // Test for a drive path only such as C: or D:)
            if (command.Length <= 3 && (command.EndsWith(":") || command.EndsWith("\\")))
            {
                DriveInfo[] drives = DriveInfo.GetDrives();
                var driveInfo = drives.Where(x => x.Name.StartsWith(command)).FirstOrDefault();
                if (driveInfo != null)
                {
                    commandAccess.SetDirectory(driveInfo.RootDirectory.FullName);
                    commandAccess.AppendOutput("", true, true);
                    return true;
                }
            }

            return false;
        }