_files folder (part 3) Special delete rules for _files folder

  • If there are sub-folders under this _files folder, you can’t simply just delete the _files folder. If you do so, you will get exception when you try to create same sub folder in same _files folder.

    • For a regular folder, you can always do this:
      1. web.Folders.Add(“Root folder”)
      2. web.Folders.Add(“Root folder/sub folder”)
      3. web.GetFolder(“Root folder”).Delete() // this will remove all folder content
      4. web.Folders.Add(“Root folder”)
      5. web.Folders.Add(“Root folder/sub folder”)
    • However for _files folder, step 5 will throw exception with message “Cannot create xxxx”. No further information available for the reason. You have to specifically delete all sub folders of it, then delete _files folder. Then you create _files folder, then sub folder.
Advertisements
This entry was posted in Document library and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s