none
FileNotFound Exception when creating folder in Sharepoint Doc Library RRS feed

  • Question

  • var addFolder = docLibrary.Items.Add("myLibrary/root Folder/testing000000123", SPFileSystemObjectType.Folder, "task1"); if (!string.IsNullOrEmpty(securityClassification) && securityClassification != "0") { addFolder["SecurityClassification"] = securityClassification;

    // the value for securityClassification is "1". this column is a lookup column } addFolder.Update();

    above is my code to create a folder in my Sharepoint document library

    my folder structure is as follows

    myLibrary

        root Folder (all new folders will be created inside here)

               task1

    the exception is not always happening

    Friday, January 27, 2017 2:37 AM

All replies

  • Hi,

    I did not validate your code, but the naming convention for your document library is seems to need correct way.

    Here are my naming convention tips for document library

    Use capital letters to delimit words.

    Do not use the _ and spaces on the file or folder name that will create ugly URL and leads to increase character length.

    Use the logically correct folder to identify easily by user and SharePoint Search crawl.

    If you want to identify the file or folder through date wise follow this simple approach

    Example

    2017Draft01Feb02 and 2017Draft01Feb03

    Do not use any special characters such as /_* and etc.




    Murugesa Pandian | MCPD | MCTS | SharePoint 2010 |


    Friday, January 27, 2017 4:33 AM
  • Hi Tan,

    As you said, this exception not always happening, can you give it a record when the error occurs? This should help to narrow down the issue.

    Moreover, please check if Murugesa’s suggestion is helpful to you.

    Best regards,

    Patrick 

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, January 30, 2017 6:34 AM
    Moderator
  • Hi.

    i have tried Murugesa way and the error still persist sometimes.

    As for recording the error, i only managed to record what is shown in the 1st post, i.e the path to the location of where the new folder is to be created and the name of the folder. 

    Tuesday, January 31, 2017 1:17 AM
  • Hi,

    If you are sure, the testing000000123 folder has been created, then navigate to the same folder, and grab the URL from the browser.

    You need to specify the correct site url, document url with correct server path and then concatenate your folder name.


    Murugesa Pandian | MCPD | MCTS | SharePoint 2010 |

    Tuesday, January 31, 2017 5:31 AM
  • hi.. i have checked and i saw the folder testing000000123  was created. i am able to access the folder from my browsers.

    the permission on the folder is being set to "Contribute" permission level for all users.

    Wednesday, February 1, 2017 3:37 AM
  • Hi,

    Does it mean that this error is thrown after the folder “testing000000123” was created?

    Please try accessing all the folders in your library in a loop, let’s see if the same error would be thrown.

    Best regards,

    Patrick

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, February 6, 2017 11:12 AM
    Moderator