Skip to main content

Run this code, will work perfectly. There I have taken "filename""filename" as a folder, - you can replace it with any folder name that you want.

ClientContext cxt = new ClientContext("http://win-8c97ll22qqc:100/sites/dev");
        List list = cxt.Web.Lists.GetByTitle("Documents");

        cxt.Load(list);
        cxt.Load(list.RootFolder);
        cxt.Load(list.RootFolder.Folders);
        cxt.Load(list.RootFolder.Files);
        cxt.ExecuteQuery();
        FolderCollection fcol = list.RootFolder.Folders;
        List<string> lstFile = new List<string>();
        foreach(Folder f in fcol)
        {
            if (f.Name == "filename")
            {
                cxt.Load(f.Files);
                cxt.ExecuteQuery();
                FileCollection fileCol = f.Files;
                foreach (File file in fileCol)
                {
                    lstFile.Add(file.Name);
                }
            }
        }

Run this code, will work perfectly. There I have taken "filename" as a folder, you can replace with any folder name that you want.

ClientContext cxt = new ClientContext("http://win-8c97ll22qqc:100/sites/dev");
        List list = cxt.Web.Lists.GetByTitle("Documents");

        cxt.Load(list);
        cxt.Load(list.RootFolder);
        cxt.Load(list.RootFolder.Folders);
        cxt.Load(list.RootFolder.Files);
        cxt.ExecuteQuery();
        FolderCollection fcol = list.RootFolder.Folders;
        List<string> lstFile = new List<string>();
        foreach(Folder f in fcol)
        {
            if (f.Name == "filename")
            {
                cxt.Load(f.Files);
                cxt.ExecuteQuery();
                FileCollection fileCol = f.Files;
                foreach (File file in fileCol)
                {
                    lstFile.Add(file.Name);
                }
            }
        }

Run this code. I have taken "filename" as a folder - you can replace it with any folder name that you want.

ClientContext cxt = new ClientContext("http://win-8c97ll22qqc:100/sites/dev");
List list = cxt.Web.Lists.GetByTitle("Documents");

cxt.Load(list);
cxt.Load(list.RootFolder);
cxt.Load(list.RootFolder.Folders);
cxt.Load(list.RootFolder.Files);
cxt.ExecuteQuery();
FolderCollection fcol = list.RootFolder.Folders;
List<string> lstFile = new List<string>();
foreach(Folder f in fcol)
{
    if (f.Name == "filename")
    {
        cxt.Load(f.Files);
        cxt.ExecuteQuery();
        FileCollection fileCol = f.Files;
        foreach (File file in fileCol)
        {
            lstFile.Add(file.Name);
        }
    }
}
deleted 48 characters in body
Source Link
ateet
  • 871
  • 5
  • 17

Run this code, will work perfectly. There I have taken "filename" as a folder, you can replace with any folder name that you want.

ClientContext cxt = new ClientContext("http://win-8c97ll22qqc:100/sites/dev");
        List list = cxt.Web.Lists.GetByTitle("Documents");
        CamlQuery query = new CamlQuery();

        cxt.Load(list);
        cxt.Load(list.RootFolder);
        cxt.Load(list.RootFolder.Folders);
        cxt.Load(list.RootFolder.Files);
        cxt.ExecuteQuery();
        FolderCollection fcol = list.RootFolder.Folders;
        List<string> lstFile = new List<string>();
        foreach(Folder f in fcol)
        {
            if (f.Name == "filename")
            {
                cxt.Load(f.Files);
                cxt.ExecuteQuery();
                FileCollection fileCol = f.Files;
                foreach (File file in fileCol)
                {
                    lstFile.Add(file.Name);
                }
            }
        }

Run this code, will work perfectly. There I have taken "filename" as a folder, you can replace with any folder name that you want.

ClientContext cxt = new ClientContext("http://win-8c97ll22qqc:100/sites/dev");
        List list = cxt.Web.Lists.GetByTitle("Documents");
        CamlQuery query = new CamlQuery();

        cxt.Load(list);
        cxt.Load(list.RootFolder);
        cxt.Load(list.RootFolder.Folders);
        cxt.Load(list.RootFolder.Files);
        cxt.ExecuteQuery();
        FolderCollection fcol = list.RootFolder.Folders;
        List<string> lstFile = new List<string>();
        foreach(Folder f in fcol)
        {
            if (f.Name == "filename")
            {
                cxt.Load(f.Files);
                cxt.ExecuteQuery();
                FileCollection fileCol = f.Files;
                foreach (File file in fileCol)
                {
                    lstFile.Add(file.Name);
                }
            }
        }

Run this code, will work perfectly. There I have taken "filename" as a folder, you can replace with any folder name that you want.

ClientContext cxt = new ClientContext("http://win-8c97ll22qqc:100/sites/dev");
        List list = cxt.Web.Lists.GetByTitle("Documents");

        cxt.Load(list);
        cxt.Load(list.RootFolder);
        cxt.Load(list.RootFolder.Folders);
        cxt.Load(list.RootFolder.Files);
        cxt.ExecuteQuery();
        FolderCollection fcol = list.RootFolder.Folders;
        List<string> lstFile = new List<string>();
        foreach(Folder f in fcol)
        {
            if (f.Name == "filename")
            {
                cxt.Load(f.Files);
                cxt.ExecuteQuery();
                FileCollection fileCol = f.Files;
                foreach (File file in fileCol)
                {
                    lstFile.Add(file.Name);
                }
            }
        }
Source Link
ateet
  • 871
  • 5
  • 17

Run this code, will work perfectly. There I have taken "filename" as a folder, you can replace with any folder name that you want.

ClientContext cxt = new ClientContext("http://win-8c97ll22qqc:100/sites/dev");
        List list = cxt.Web.Lists.GetByTitle("Documents");
        CamlQuery query = new CamlQuery();

        cxt.Load(list);
        cxt.Load(list.RootFolder);
        cxt.Load(list.RootFolder.Folders);
        cxt.Load(list.RootFolder.Files);
        cxt.ExecuteQuery();
        FolderCollection fcol = list.RootFolder.Folders;
        List<string> lstFile = new List<string>();
        foreach(Folder f in fcol)
        {
            if (f.Name == "filename")
            {
                cxt.Load(f.Files);
                cxt.ExecuteQuery();
                FileCollection fileCol = f.Files;
                foreach (File file in fileCol)
                {
                    lstFile.Add(file.Name);
                }
            }
        }