pesso said:
How can I write a newsreader in .NET?
Hi pesso,
there is already an implementation of an ADO.NET Data Provider for NNTP
by Dirk_Primbs [MS].
http://workspaces.gotdotnet.com/nntpClient
This library allows you to code like this:
- Simple access using a DataReader:
NntpConnection cn = new NntpConnection("news.microsoft.com");
NntpCommand cmd = new NntpCommand("select top 10 * from
microsoft.public.dotnet.languages.csharp", cn);
cn.Open();
NntpDataReader reader = cmd.ExecuteReader();
while(reader.Read())
Console.WriteLine("{0}\t{1}\n", reader.GetString("From"),
reader.GetString("Subject"));
cn.Close();
- Getting a DataSet:
DataSet ds = new DataSet();
NntpConnection cn = new NntpConnection("news.microsoft.com");
NntpCommand cmd = new NntpCommand("select top 10 * from
microsoft.public.dotnet.languages.csharp", cn);
NntpDataAdapter da = new NntpDataAdapter(cmd);
da.Fill(ds);
It is also possible to post a message:
NntpPosting:
NntpConnection cn = new NntpConnection("news.microsoft.com");
cn.Open();
NntpPosting p = new NntpPosting("Arne Janning",
"(e-mail address removed)", "Re: fourtytwo", "This is a test.",
"microsoft.test");
p.Post(cn);
cn.Close();
If you use the DataAdapter, just call the Update()-Method.
Cheers
Arne Janning