Monday 18 June 2007

Adding a document to a Document library

Here is one that stumped me for a while

One of my fellow developers had a web part that needed to convert a xml file to a pdf and then add the pdf to a document library . Well the conversion worked and everything was fine except he couldn’t workout how to get the pdf in to a document library.
There are no overrides on the .Add() method of the SPListItemCollection Class that take File in to account, the .File propriety is only a get and we didn’t know what Field to use. Evan the SPDocumentLibrary class was of no use.

After a bit of head scratching we found that we needed to use the list.Rootfolder.Files.add

This is in the SDK on one line in one of the related classes but I can’t find it again

Hopefully this post will help anyone else that gets snagged on this simple process

A useful tip

The Add method of the SPFilecolection returned a SPFile object
So you can use this code to add your relevant meta data

SPFile newFile = list.Rootfolder.Files.add( fileURL, fileStream);
SPListItem fileItem = newFile.Item;



Hope that help

Tuesday 12 June 2007

Noooo SharePoint Blogs is down

SharePoint Blogs is down...
One of the best resorces bor a bumbling MOSS newbee developers like my self
But there is light at the end of the tunnel as it is all is not lost
Thanks to Andrew Connell posting info on the problem
SharePointBlogs.com public service announcement

Heres to hoping you will be back up and running soon

Monday 11 June 2007

Stsadm export / import comand Errors to catch us

Migrating a sub site from one location to another within a single Site Collection.

After a short search you will find that most places point you towards Stsadm.exe -export / import and most of these tuts and How to’s are complete so no need to Blog it again (besides I could not do half as good a job) But what I want to highlight is errors that I have come across when using the commands that I can’t find answers to

Firstly the size of the sub site
When using stsadm.exe export the exported data is not written to destination disk till after the export is complete so if the sub site is larger than the free space on the system disk the export will fail.
Not much can be done around this one you can try reduce the amount of information exported by using the –versions command or create your own migration tool using the API’s
If you know any good way around this please add a comment.

Next Lists with e-mail address
If a list has an attached incoming email address and the Portal incoming email settings Directory Management Service is set to yes. The import fails as it can’t create the email address as it all ready exists short of removing all e-mail support from these lists and redoing the export and import then add email association to the newly imported lists
Best way I have found is to drop all list email association and then do the export and import then add the associations to the new lists.
If you know any good way around this please add a comment.

Lets start exposing my lack of anything

Well i read somewere that app developers should have a blog (evan if they have nothing usefull to say) so here are my ramblings.
This blog is about MOSS 2007. I have only started on MOSS and have a measly 1 month of it behind me.