Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Suggested answer

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

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

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,768 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,985 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans