Hi @MW ,
According to my research and testing, I recommend you use the following code to get files in folder via CSOM:
static void Main(string[] args)
{
var cc = GetonlineContext();
cc.Load(cc.Web, p => p.Title);
cc.ExecuteQuery();
List list = cc.Web.Lists.GetByTitle("<List-Name>");
cc.Load(list);
cc.Load(list.RootFolder);
cc.Load(list.RootFolder.Folders);
cc.Load(list.RootFolder.Files);
cc.ExecuteQuery();
FolderCollection fcol = list.RootFolder.Folders;
foreach (Folder f in fcol)
{
if (f.Name == "<Folder-Name>")
{
cc.Load(f.Files);
cc.ExecuteQuery();
FileCollection fileCol = f.Files;
foreach (File file in fileCol)
{
Debug.WriteLine(file.Name);
}
}
}
}
My test result:
Hope it can help you. Thanks for your understanding.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.