How to retrieve path of file from sharepoint site?

Hi Guys,

Our requirement is as below:
In a library, n number of folders/sub folders can be there. So we want to filter that library first on value of a column. Once that is done, it will show list of all files(from folder/sub-folders).

Now we want to download all the files that are shown after filtering.

Is there a way, we can also retrieve the file path on sharepoint with the file?


Hi @sonaliaggarwal47,

We have previously used this approach.

Manually: You can try opening the SharePoint folder via windows explorer. This will for the given session map the SharePoint folder as a network drive (will ask for authentication before mapping the drive).

Later we used custom C# code to download the files in the folder using the Fullpath (which is a URL). We used C# because Directory.GetFiles does not support URL based Mapped drive locations/paths.

Programatically: You can also use net use command in cmd or PowerShell to map network drives / SharePoint folders programatically. More info on Net use Net use | Microsoft Docs

Net use can help shorten the URL path by mapping to the Nth parent folder of the file but still the FullPath to your file will be read as a Network Drive.

Network drives dont gel so well with UiPath (I read in some release post that UiPath will support network drive file downloads) so until then I would suggest you build up a reusable C# library which can download/delete/copy/move files in a network drive.
You can start here : WebClient.DownloadFile Method (System.Net) | Microsoft Docs

Hi @jeevith,

Thank you for your inputs.

We tried below approach, worked well (intention was more around being able to achieve this without writing any script).

  1. Use package UiPathTeam.Sharepoint.Activities
  2. Use activity “Get list items” defining the filter under CAML query
  3. Save the output as datatable
  4. Write the datatable output in .csv file
  5. It gives whole list of columns/properties attached to that file(few mentioned as below:)
    FileLeafRef → gives the name of the sharepoint file retrieved
    FileRef → gives the sharepoint file full path (along with the file name)
    FileDirRef → gives the sharepoint file path (without file name at the end)

Apart from this, many more columns are retrieved like created by/on, modified by/on, file size, site url etc.

Please refer below attached file for columns retrieved.
Get list items output.xlsx (11.4 KB)


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.