I recommend you to check out Sense/Net - it's free and open source.
It's one of the few open source software that supports document management with the office protocol. So you can just click on a link on a site and it will automaticall open your files with Microsoft Office. It also supports versioning and many other features.
You can have a look at their source code and releases here:
http://sensenet.codeplex.com/