Skip to main content
Dynamics 365 general forum
Suggested answer

Not able to get the file name from sharepoint . But able to get the object from it

editSubscribe (0) ShareShare
ReportReport
Posted on by 30

Trying to get the file name which is already there in the sharepoint folder. The problem is ,I have to get all the files in the sharepoint folder. So trying to get the files and find the name from it. But could not acheive it. If anyone have any idea, Please suggest.

pastedimage1674124351877v1.pngpastedimage1674124773483v1.png

  • Suggested answer
    Naveen Ganeshe Profile Picture
    Naveen Ganeshe 3,392 Super User on at
    RE: Not able to get the file name from sharepoint . But able to get the object from it

    Good to know that, You cracked this

  • Suggested answer
    Anoop B Profile Picture
    Anoop B 30 on at
    RE: Not able to get the file name from sharepoint . But able to get the object from it

    Worked fine like this!

    pastedimage1674136388610v1.png

  • Naveen Ganeshe Profile Picture
    Naveen Ganeshe 3,392 Super User on at
    RE: Not able to get the file name from sharepoint . But able to get the object from it

    Hi Anoop,

    Please take a look at the sample from Microsoft to interact with Sharepoint:

    learn.microsoft.com/.../sample-create-retrieve-update-delete-sharepoint-location-record

    Also, You can follow the below code as well:

    using (ClientContext clientContext = new ClientContext("https://yourtenant.sharepoint.com/sites/yourSite"))
    {
        SecureString passWord = new SecureString();
        foreach (char c in "password".ToCharArray()) passWord.AppendChar(c);
        clientContext.Credentials = new SharePointOnlineCredentials("username", passWord);
        Web web = clientContext.Web;
        List list = web.Lists.GetByTitle("yourListTitle");
        CamlQuery query = CamlQuery.CreateAllItemsQuery();
        ListItemCollection items = list.GetItems(query);
        clientContext.Load(items);
        clientContext.ExecuteQuery();
        foreach (ListItem item in items)
        {
            Console.WriteLine(item.FieldValues["FileLeafRef"]);
        }
    }
    


Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,066 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,585 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans