public void AddFile(string directory, FtpItem item, string text, Encoding encoding) { var uri = GetUri(directory, item.Name); var data = encoding.GetBytes(text); item.Length = data.Length; if (_dict.ContainsKey(uri)) { _dict[uri] = data; } else { _dict.Add(uri, data); } if (_uri_ftpitem.ContainsKey(uri)) { _uri_ftpitem[uri] = item; } else { _uri_ftpitem.Add(uri, item); } }
// Static members public static IEnumerable<FtpItem> Parse(string s) { var list = new List<FtpItem>(); foreach (string line in s.GetLines()) { var m = Regex.Match ( line, @"^ (?<month>\d\d)-(?<day>\d\d)-(?<year>\d\d)\s+(?<time>\S+)\s+ (?<length>\d+)\s (?<name>.+) $", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace ); if (!m.Success) { continue; } var date = DateTime.Parse(m.Groups["time"].Value); date = new DateTime ( 2000 + int.Parse(m.Groups["year"].Value), int.Parse(m.Groups["month"].Value), int.Parse(m.Groups["day"].Value), date.Hour, date.Minute, 0 ); var item = new FtpItem() { Length = long.Parse(m.Groups["length"].Value), Name = m.Groups["name"].Value, Date = date, }; list.Add(item); } return list; }