cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We've been busy working on some major updates to the Community, so check out what's changing, what’s staying the same and what you can expect from the Dropbox Community right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dropbox api. not worked foreach (var item in list.Entries.Where(i => i.IsFolder))

Dropbox api. not worked foreach (var item in list.Entries.Where(i => i.IsFolder))

saharin
Explorer | Level 4

I want to use the dropbox api. I use the code from this page - https://www.dropbox.com/developers/documentation/dotnet#tutorial .

But in my Visual.Studio throws an error -
CS1061 "IList<Metadata>" does not contain a definition of "Where", and it was not possible to find an available "Where" extension method that accepts the type "IList<Metadata>" as the first argument (perhaps the using directive or assembly reference was omitted).
Why doesn 't it recognize WHERE ?

 

Code:

async Task ListRootFolder(DropboxClient dbx)
{
var list = await dbx.Files.ListFolderAsync(string.Empty);

// show folders then files
foreach (var item in list.Entries.Where(i => i.IsFolder))
{
Console.WriteLine("D {0}/", item.Name);
}

foreach (var item in list.Entries.Where(i => i.IsFile))
{
Console.WriteLine("F{0,8} {1}", item.AsFile.Size, item.Name);
}
}

11 Replies 11

Здравко
Legendary | Level 20

Hi @saharin,

Hm..🤔 It's something strange - seems like a problem of your environment (Visual Studio in the case).

Try something like following simpler code:

async Task ListRootFolder(DropboxClient dbx)
{
    var list = await dbx.Files.ListFolderAsync(string.Empty);

    foreach (var item in list.Entries)
    {
        Console.WriteLine("{0} {1,10} {2}", item.IsFolder ? "D->" : "F->",
          item.IsFolder ? "" : item.AsFile.Size.ToString(), item.Name); 
    }
}

Does this show the same (or some other) error?

Greg-DB
Dropbox Staff

@saharin I just tried out that original code sample, and it worked for me.

 

If you're still having trouble with this, can you let me know the version numbers of each of the following that you're using?

  • Visual Studio
  • .NET Framework
  • Dropbox .NET package

saharin
Explorer | Level 4

This ok, thanks!

saharin
Explorer | Level 4

VS - 2019

.NET 5.0

dropbox api 6.37.0

Greg-DB
Dropbox Staff

@saharin Can you clarify what you mean when you say "This ok"? Have you resolved this issue?

saharin
Explorer | Level 4

Still, no, it does not work, the code that was thrown to me does not cause errors, but the list of cloud storage files does not print.

Здравко
Legendary | Level 20

@saharin, That's definitely related to your environment and not to Dropbox API/SDK. You should investigate further what's wrong there. 🤷

 


@saharin wrote:

..., but the list of cloud storage files does not print.


It could be wrong expectation. Depending on your environment settings, the console, where output prints out, can stay open after your program finishes or can close immediately (and that's why you cannot see anything). Check this and tune it or run your application (after build) in independent terminal, so it will stay open and you able to see your application result. 😉

Good luck.

Greg-DB
Dropbox Staff

@saharin Thanks for following up. Unfortunately as we cannot reproduce this issue, and this functionality is not actually part of the Dropbox API/SDK itself, I'm afraid I can't offer much insight on this.

 

For reference, the "Where" method is provided by Microsoft, and you can find information on that here.

 

I see you said you're using .NET 5 though, and I believe Microsoft no longer supports that version, so you may want to upgrade that.

 

saharin
Explorer | Level 4

there is no console I definitely do not close, I looked through debugging

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Здравко Legendary | Level 20
  • User avatar
    saharin Explorer | Level 4
What do Dropbox user levels mean?