예제 #1
0
        public static IEnumerable <SevenItem> List(string archPath, string filter = null)
        {
            if (!File.Exists(archPath))
            {
                throw new FileNotFoundException("cannot found archieve");
            }
            var startInfo = new ProcessStartInfo()
            {
                FileName               = SevenZipPath,
                UseShellExecute        = false,
                CreateNoWindow         = true,
                WorkingDirectory       = WorkDir,
                Arguments              = $"l \"{archPath}\" {filter ?? ""}",
                RedirectStandardOutput = true,
            };
            var p = Process.Start(startInfo);

            p.WaitForExit();
            while (!p.StandardOutput.EndOfStream)
            {
                var line = p.StandardOutput.ReadLine();
                if (SevenItem.IsItem(line))
                {
                    yield return(SevenItem.Parse(line));
                }
            }
        }
예제 #2
0
        public static SevenItem Parse(string line)
        {
            var match = reg.Match(line);

            if (!match.Success)
            {
                throw new ArgumentException("does not match");
            }
            var item = new SevenItem
            {
                time     = DateTime.Parse(match.Groups[1].Value),
                type     = ParseAttr(match.Groups[2].Value),
                realSize = int.Parse(match.Groups[3].Value),
                size     = int.Parse(match.Groups[4].Value),
                path     = match.Groups[5].Value,
            };

            return(item);
        }