Raj M. posted this anonymously in the Windows Services newsgroup.
"Here are the exact steps for newbie.
1. Create the Windows Application or Console Application
2. Add the reference to Microsoft.SharePoint.dll
3. Copy the following code
using Microsoft.SharePoint;
SPSite site = new SPSite("
http://localhost:9328");
SPWeb web = site.OpenWeb();
SPFolder myFolder = web.Folders["Shared Documents"];
//max versions to keep.
int maxVersions = 0;
foreach (SPFile myFile in myFolder.Files )
{
int nDocVersions = myFile.Versions.Count;
while ((maxVersions > 0) && (nDocVersions > (maxVersions - 1)))
{
myFile.Versions.Delete(0);
nDocVersions = myFile.Versions.Count;
}
}
4. Compile the code.
Thanks to Raj M. (if he objects to me quoting him, he should contact me)