synchronization - Using C# to access OneDrive For Business (Office365) - Can't list subfolders -


Trying to write the contents of my company's users to download "one drive" on the company network so that we can delete them if we can return them

I currently use Microsoft.SharePoint I am using .client. I also distinguish OneDrive for Business from OneDrive for the impression (enough to confuse it with Sharepoint). For example ... if my OneDrive url

I can successfully list all the files in the root of the documents and download all the files in the root of the document folder.

  Public Zero List Files () {var Folders = Listfolders (Dirpath, Client Contract, Web);  

// Now do something with the results contained in 'folders' public listing GetDocumentLibrary (string library name, client contact client contact, web web) {var query = clientContext.LoadQuery (web.lists.Where (p = & Gt; p.Title == libraryName)); ClientContext.ExecuteQuery (); Return query. FirstOver Default (); } Public listing & lt; Folder & gt; Listfolders (String LibraryName, ClientContact Client Contact, Web Web) {var list = GetDocumentLibrary (LibraryName, Client CONTACTS, WEB); Var folder = list.RootFolder.Folders; ClientContext.Load (folder); ClientContext.ExecuteQuery (); Return Folders. Toolist (); }

This code works fine to return a list of folders within the document folder, however, my problem is trying to list the contents of one of these folders .

Like

If I try to run the same code above, then this time the exception is thrown to me.

  An unmanaged exception of 'Microsoft.SharePoint.Client.ClientRequestException' type Additional information in Microsoft.SharePoint.Client.dll: The site at the specified URL can not contact https: // accountname -my.sharepoint.com/personal/firstname_lastname_mycompany_com/Documents This is happening in the ExecuteQuery () statement in GetDocumentLibrary (), I do not understand why a web name "/ personalal_firstname_lastname_mycompany_com / Documents / _vti_bin / sites.asmx"  

This is not returning any results, as I documented the client's convertrait and web Instead of pointing at John turned to query for the new URL.

Does anyone have any idea why he is seeing /_vti_bin/sites.asmx, if someone has a suggestion where I am getting wrong?

Is this the right way I am going? Does SharePoint / OneDrive matter for subfolders for business? Is it something Microsoft is weird?

Many thanks

Dougie

You are getting This error because you have to send your OneDrive URL to the Business Document Library on your OneDrive for the business site rather than the URL in the context of the customer.

Example you are probably doing this:

  New Client CONTACTS ("https://accountname-my.sharepoint.com/personal/firstname_lastname_mycompany_com/Documents/")  

When you should do this:

  New Client Contact ("https://accountname-my.sharepoint.com/personal/firstname_lastname_mycompany_com/")  

Note that the "document" part of the URL is a document library, which is not a site. You will have to pass a site URL in a new client contact () which is why you get the error.

You will need some recursive or similar to list all the folders. Once you get the initial list of root folders, then for each folder in that list:

  clientContext.Load (folder.Folders); ClientContext.ExecuteQuery ();  

and then come back to the same folder for each folder. Unless you have a complete list of folders.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -