public static OsDisk MatchResultToOsDisk(byte[] resultBytes, Encoding encode) { string result = GetResultFromInterval(resultBytes, encode); string pattern = @"^(?<ShellDir>.*?)\t(?<AvailableDisk>.*?)$"; Regex regex = new Regex(pattern, RegexOptions.Singleline); Match m = regex.Match(result); if (!m.Success) { throw new ResponseCustomException("匹配返回结果", "匹配失败", result); } else { OsDisk disk = new OsDisk(); disk.ShellDir = m.Groups["ShellDir"].Value; disk.AvailableDisk = m.Groups["AvailableDisk"].Value; return(disk); } }
public static OsDisk MatchResultToOsDisk(byte[] resultBytes, Encoding encode) { string result = GetResultFromInterval(resultBytes, encode); string pattern = @"^(?<ShellDir>.*?)\t(?<AvailableDisk>.*?)$"; Regex regex = new Regex(pattern, RegexOptions.Singleline); Match m = regex.Match(result); if (!m.Success) { throw new ResponseCustomException("匹配返回结果", "匹配失败", result); } else { OsDisk disk = new OsDisk(); disk.ShellDir = m.Groups["ShellDir"].Value; disk.AvailableDisk = m.Groups["AvailableDisk"].Value; return disk; } }