/// <summary> /// Gets new article info for newsgroups. /// </summary> public void GetNewNews(string groups,DateTime since,NNTP_Articles articles) { byte[] fileData = null; int msgNo = 1; Hashtable files = new Hashtable(); NNTP_NewsGroups newsgroups = ParseNewsGroups(groups); foreach(NNTP_NewsGroup group in newsgroups.Newsgroups) { string groupPath = group.Name.Replace(".","\\"); string path = m_NNTPStorePath + "groups\\" + groupPath; if(!Directory.Exists(path)){ Directory.CreateDirectory(path); AddGroup(group.Name); } string[] articls = Directory.GetFiles(path,"*.txt"); foreach(string articl in articls) { using(FileStream fs = File.OpenRead(articl)) { fileData = new byte[fs.Length]; fs.Read(fileData,0,(int)fs.Length); } HeaderParser hp = new HeaderParser(fileData); msgNo = Convert.ToInt32(Path.GetFileNameWithoutExtension(articl).Substring(0,Path.GetFileNameWithoutExtension(articl).IndexOf("_"))); string date = hp.MessageDate.ToString(); if(Convert.ToDateTime(date).CompareTo(since) > 0) { articles.Add(hp.MessageID,msgNo,hp.Subject,hp.From,date,hp.References,hp.Lines,fileData.Length.ToString()); } } } }
/// <summary> /// Gets article info for a newsgroup. /// </summary> public void GetArticles(string group,NNTP_Articles articles) { byte[] fileData = null; int msgNo = 1; Hashtable files = new Hashtable(); group = group.Replace(".","\\"); string path = m_NNTPStorePath + "groups\\" + group; if(!Directory.Exists(path)) { Directory.CreateDirectory(path); AddGroup(group); } string[] articls = Directory.GetFiles(path,"*.txt"); foreach(string articl in articls) { using(FileStream fs = File.OpenRead(articl)) { fileData = new byte[fs.Length]; fs.Read(fileData,0,(int)fs.Length); } HeaderParser hp = new HeaderParser(fileData); msgNo = Convert.ToInt32(Path.GetFileNameWithoutExtension(articl).Substring(0,Path.GetFileNameWithoutExtension(articl).IndexOf("_"))); string date = hp.MessageDate.ToString(); articles.Add(msgNo,hp.MessageID,hp.Subject,hp.From,date,hp.References,hp.Lines,fileData.Length.ToString()); } }