0

I am getting following exception while trying to add a file :

SPException: It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web.

Code for uploading :

spFile = spWeb.Files.Add(
                        docUrl,
                        uploadStream,
                        true, // overwrite or add a new version
                        uploadMessage.Metadata.CheckInComment ?? "", //check-in comment to use when creating the file in the collection. (can't be NULL)
                        false); // don't check the required fields when saving the file

The issue does not occur while manually uploading the file from the browser but while adding the file in a Document Library from the code using SPWeb.Files.Add the above mentioned exception occurs. Please note that the Content DB of the web application is not full.

  • Could you share the code snippet. – Garima Feb 9 '15 at 12:45
  • I've added code snippet – Akash KC Feb 9 '15 at 12:56
  • How you have initialized spWeb? I mean what is the context? Root/Site? Could you please share the snippet of initialization? – 404 Feb 9 '15 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.