Add a document to Sharepoint (MOSS) from a batch job.

I was recently talking to a customer, who needs a daily batch job for checking the contents of a database. The checking results in a PDF listing, that needs to be kept at hand.

My suggestion was to e-mail the list to him at the end of the batch job, but then the customer suggested that the listing be stored in a MOSS document library instead. I my opinion a brilliant idea! A mailbox is 1) a personal data store and 2) a place with far too much information bundled together, so I think that using MOSS is just the right solution for sharing and storing.

Only, I didn’t really know how to go about it. Looking into the MOSS API revealed lots of functionality but no easy solutions. Googling around found some ADODB(!) samples that didn’t work. One would have thought that some genius at MS would have thought of this requirement before, and that a standard tool would be available, but apparently this is not the case. I then mulled over this for a while, not wanting to make a development project out of it – however interesting that might be.

The solution came via someone telling me, that you can actually add a MOSS document library to the filemanager via WebDAV and use it as an ordinary file share – a very cool feature indeed. Then it dawned upon me that a standard WebDAV tool might exist, and it took only a couple of minutes to find DavCopy, which is more or less XCopy for DAV, and thus for MOSS.

A line in a .BAT file might be:

davcopy dailyreport_20070619.pdf “http://mymoss/websteder/LandbrugsIT/Delte dokumenter

Long live the KISS principle!

Posted in C#

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s