DirectoryInfo.EnumerateFiles() result is empty on Ubuntu

534 Views Asked by At

I am looking at System.IO and wrote a small method to count the number of files in a directory. The problem I have is that when I debug this piece of code in windows, I can enumerate over the collection when I hover over the collection. So here is the code and the image in Visual Studio on Windows.

File Enumeration while debugging

Here is the code in question:

static void Main(string[] args)
{
    var dir = new DirectoryInfo(@"/home/user1/Downloads/Folder that 
                  has spaces in name");
    var files = dir.EnumerateFiles();
    var count = files.Count();
    Console.WriteLine($"Number of files in Videos Folder is {count}");
}

This is what I get when I run same lines of code on ubuntu:

Error while running code in ubuntu

Can someone help me understand what is going on here? Both folders have files in them and permissions is not a problem since I am working with a folder in my home directory (\home\user\Downloads\Videos). Folder names aren't a problem as I already checked.

0

There are 0 best solutions below