Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am using the SharePoint Client Object Model to get information from a SharePoint 2010 document library to be able to delete old htm-files located there. The problem is that these htm-files have hidden "_files"-folders associated to them. I am not able to find these folders using the SharePoint Client Object Model, they just don't show up. I can see them in Windows Explorer using WebDav, but not in SharePoint. They don't get deleted if I just delete the .htm-file.

 using (ClientContext context = new ClientContext(webUrl))
        {
            Web web = context.Web;
            context.Credentials = System.Net.CredentialCache.DefaultCredentials;
            context.Load(web);
            context.ExecuteQuery();
            Folder fldr = web.GetFolderByServerRelativeUrl(serverRelativeFolderUrl);
            context.Load(fldr);
            context.Load(fldr.Folders);
            context.ExecuteQuery();
            foreach (Microsoft.SharePoint.Client.Folder folder in fldr.Folders)
            { // no hidden folders found here, only usual folders
                Console.WriteLine(folder.Name);
            }
        }
share|improve this question

1 Answer 1

According to http://blogs.msdn.com/b/findnavish/archive/2011/11/16/some-specific-folder-or-files-not-getting-created-in-sharepoint-thickets.aspx and http://social.technet.microsoft.com/Forums/windows/en-US/d6c187ab-3d70-4357-878f-018b9731c161/sharepoint-folder-with-an-underscore-contained-within you shouldn't be able to upload the folders without getting renamed to *_files_. Are the folders there without the trailing underscore?

If yes, and you somehow really created thickets you won't see them - they won't reveal as they are beliefed as "internal" and never be listed in the OM. You can still delete them though:

SPFolder folder = web.GetFolder("Documents/google_files")
//while folder.Exist is false the folder could still exist but be hidden
folder.Delete()

This won't throw an exception if the folder is not found and delete if it exists.

Edit, after finding out that you are searching for a method to do this automatically

You could create an EventReceiver that handles the situation of a file getting deleted and delete the ticket folder to the .htm file accordingly. In the example on http://msdn.microsoft.com/en-us/library/ms453149.aspx they are canceling the ItemDeleting event, you just have to catch the event occuring in the libraries you want (The event will fire on all items in a web) and delete the thicket.

Just a hint when doing so, Sharepoint Manager (http://spm.codeplex.com) is a great tool that helps you stumbling through the objects on your SharePoint. It has done a great job for me when i was deploying features and custom Receivers into SharePoint.

share|improve this answer
    
I am able to upload the thickets without them getting renamed, using the SharePoint Webservices. This also is the behaviour I want. The issue is that the .htm-files were deleted using the SharePoint website, so if I want to delete the _files I would need to find the folders as I don't know the .htm-file anymore. Our current workaround is a manual webdav-search. This also has the disadvantage of the files being in the recycle bin for 30 days after deletion - the web frontend is not able to delete these 1000s of files from the bin without timing out. –  Compufreak Jul 29 at 11:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.