Skip to content

Unable to read file from folder #1322

Answered by jansenbe
shabirjan asked this question in Q&A
Discussion options

You must be logged in to vote

@shabirjan : this works for me:

var documentFolder = (await context.Web.Lists.GetByTitleAsync("graph", p => p.RootFolder));
var allStoreFolders = (await documentFolder.RootFolder.GetAsync(f => f.Folders)).Folders;

foreach (var folder in allStoreFolders.AsRequested())
{

    //  Console.WriteLine(folder.Name);
    if (folder.Name == "Folder1")
    {
        Console.WriteLine("Folder Found");

        foreach (var file in folder.Files)
        {
            var extension = Path.GetExtension(file.Name);
            if (extension == ".docx")
            {
                Console.WriteLine($"Filename: {file.ServerRelativeUrl}");
            }
        }
    }
}

This however is quite similar to…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@shabirjan
Comment options

@jansenbe
Comment options

@shabirjan
Comment options

@jansenbe
Comment options

Answer selected by shabirjan
@shabirjan
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants