Wednesday, 27 October 2010

The URL ... It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web"

Today I got this error and it took me a while before I found the solution.

The error occured when I was trying to upload a Word document to a Document Library. I did not even get the form where I could add the required data. Meanwhile creating a new document was no problem.
The Docuemnt Library was a default library, where I had programmatically added a few columns.

I began to start focusing on these column, and I deleted them one after another an then, BINGO! When I deleted a SPFieldBoolean column, I could suddenly upload documents.
This columns default property was set to "Yes" and this was all wrong.
Even though its a string property it shall be set to either 0 or 1 meaning no and yes.

Lesson learned.


chendrayan said...

I have the same error in my production environment and test works fine. Can you please suggest me your solution? the way you presented is not clear for me

Martin Svendsen said...

Sorry for my late answer.

Programmatically i added the fields in a featurereceiver.

First i have added the field like this:

SPFieldBoolean fieldBoolean = (SPFieldBoolean)list.Fields.CreateNewField(SPFieldType.Boolean.ToString(), "Boolean test");
fieldBoolean.DefaultValue = "Yes";

But the right way is:

SPFieldBoolean fieldBoolean = (SPFieldBoolean)list.Fields.CreateNewField(SPFieldType.Boolean.ToString(), "Boolean test");
fieldBoolean.DefaultValue = "0";

I hope it helps :-)