Skip to main content

technical blog

Go Search
Home
Technical Blog
Resumé
Travel
Skydiving
Contact
  
Random Image

chrishines.com > technical blog > Categories
"File Not Found" on SharePoint site creation
Receiving a "File Not Found" error on SharePoint site creation is likely to be due missing files from your site definition. When defining a new site definition using an ONET.XML often specific resources are referred to which, at site creation time, are copied into the new site. For example, my ONET.XML was referring to:

DOCTEMP\XL\XLTMPL.XLS

But this file was actually missing from my definition, so my site creation failed.
SharePoint Object Model Oddity
So I have been working a lot with the SharePoint object model recently to do things like modify lists and add document libraries.

One real oddity I have come across has been adding a new document library and setting it to be displayed in the Quick Launch menu. Pretty much everything in SharePoint is a list (SPList) and a Document Library is no exception. I had no real difficulty adding the new document library, the API “does what it says on the tin”. However, I came a bit unstuck when trying to set the OnQuickLaunch property of the SPList to True. I just could not get it to appear in the Quick Launch! My code was as follows:

Dim swRootWeb As SPWeb = ssSite.RootWeb
swRootWeb.Lists.Add(strName, "description",SPListTemplateType.DocumentLibrary)
swRootWeb.Update()
swRootWeb.Lists(strName).OnQuickLaunch = True
swRootWeb.Lists(strName).Update()
swRootWeb.Update()

I can not explain why the solution I found works. However, I discovered by declaring the newly created list as a local variable and then calling the Update method on this object, rather than on the SPListCollection(i), the Update works as expected and the new Document Library is added into the Quick Launch:

Dim swRootWeb As SPWeb = ssSite.RootWeb
swRootWeb.Lists.Add(strName, "description", SPListTemplateType.DocumentLibrary)swRootWeb.Update()
Dim slNewList As SPList = swRootWeb.Lists(strName)
slNewList.OnQuickLaunch = True
slNewList.Update()
swRootWeb.Update()