public static void ParseCommand(string command) { if (string.IsNullOrWhiteSpace(command)) { return; } string[] commandParts = command.Split(' '); if (commandParts.Length >= 2 && commandParts[0].ToLower() == "ls" && FMLib.isDirectoryExist(commandParts[1])) { currentDirectory = FMLib.GetFullPath(commandParts[1]); if (commandParts.Length == 4 && commandParts[2] == "-p" && Int32.TryParse(commandParts[3], out int p)) { page = p; } else { page = 1; } } if (commandParts.Length >= 2 && commandParts[0].ToLower() == "cd" && FMLib.isDirectoryExist(commandParts[1])) { currentDirectory = FMLib.GetFullPath(commandParts[1]); FMLib.ChangeDirectory(FMLib.GetFullPath(commandParts[1])); page = 1; } if (commandParts.Length == 2 && commandParts[0].ToLower() == "info") { currentInfoItem = FMLib.GetFullPath(commandParts[1]); } if (commandParts.Length == 3 && commandParts[0].ToLower() == "copy") { try { FMLib.Copy(commandParts[1], commandParts[2]); } catch (Exception ex) { WriteEvent(ex.Message); } } if (commandParts.Length == 2 && commandParts[0].ToLower() == "delete") { try { FMLib.Delete(commandParts[1]); } catch (Exception ex) { WriteEvent(ex.Message); } } }
private static void LoadSettings() { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (config.HasFile) { pageSize = Convert.ToInt32(config.AppSettings.Settings["pageSize"].Value); } var roaming = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming); var fileMap = new ExeConfigurationFileMap() { ExeConfigFilename = roaming.FilePath }; config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); if (config.HasFile) { if (config.AppSettings.Settings.AllKeys.Contains("currentDirectory") && FMLib.isDirectoryExist(config.AppSettings.Settings["currentDirectory"].Value)) { currentDirectory = config.AppSettings.Settings["currentDirectory"].Value; FMLib.ChangeDirectory(config.AppSettings.Settings["currentDirectory"].Value); } if (config.AppSettings.Settings.AllKeys.Contains("currentInfoItem")) { currentInfoItem = config.AppSettings.Settings["currentInfoItem"].Value; } if (config.AppSettings.Settings.AllKeys.Contains("page")) { page = Convert.ToInt32(config.AppSettings.Settings["page"].Value); } } }