Happy 2006! Annually I make the silly pledge to myself that I'll try to drink less, eat less and exercise more in the coming year. That usually lasts until January 5th or so. This year, I'm not going to bother. Instead, I'm making a resolution to try and post at least three times a week to this blog. And hopefully, they'll be useful things. Let's start with something that's really a blast from the past.
Back in the year 2000, I worked on Professional Data Access for the old Wrox press. I covered the Internet Publishing Provider. Even at the time, this seemed to be an awful stretch of the "Universal Data Access" theme classic ADO had. At the time (and still somewhat today), it feels a bit kludgey to be representing files as records and if you wanted to access the file itself... well, the phrase "arcane" comes to mind. Still, I hadn't touched this stuff since moving over to .NET, so when the opportunity to do so came up on a mailing list, I jumped on it. Here's a simple little C# application that dumps all public files in all of the public directories for the local Web Server (assuming you have FPSE or WebDAV enabled).
using System;
using System.Data;
using System.Data.OleDb;
namespace InetCataloger
{
class Program
{
const string _HOSTNAME = "http://localhost";
const string _ROOT = "/";
static readonly string _CONNSTR = "Provider=MSDAIPP.DSO.1;Data Source=" + _HOSTNAME;
static void WalkFolder(string URL)
{
using (OleDbConnection conn = new OleDbConnection(_CONNSTR))
{
conn.Open();
using (OleDbCommand cmd = conn.CreateCommand())
{
cmd.CommandText = URL;
cmd.CommandType = CommandType.TableDirect;
using (OleDbDataReader dr = cmd.ExecuteReader())
while (dr.Read())
if (dr.GetBoolean(12))
WalkFolder(dr.GetString(2));
else
Console.WriteLine("{0} dated {1}", dr[2], dr[10]);
}
}
}
static void Main(string[] args)
{
WalkFolder(_ROOT);
Console.ReadLine();
}
}
}
There's a bit more documentation in the MSDN library about the IPP and the constants used in this program, but note that getting a file now returns 21, not 18 field/properties.