diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs
index 9e4e6233ac..6bcef4d077 100644
--- a/MediaBrowser.Api/EnvironmentService.cs
+++ b/MediaBrowser.Api/EnvironmentService.cs
@@ -1,5 +1,4 @@
using MediaBrowser.Common.Net;
-using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Net;
using ServiceStack.ServiceHost;
@@ -206,19 +205,40 @@ namespace MediaBrowser.Api
/// IEnumerable{FileSystemEntryInfo}.
private IEnumerable GetFileSystemEntries(GetDirectoryContents request)
{
- var fileSystemEntries = FileSystem.GetFileSystemEntries(request.Path, "*", request.IncludeFiles, request.IncludeDirectories).Where(f => !f.IsSystemFile);
-
- if (!request.IncludeHidden)
+ var entries = new DirectoryInfo(request.Path).EnumerateFileSystemInfos("*", SearchOption.TopDirectoryOnly).Where(i =>
{
- fileSystemEntries = fileSystemEntries.Where(f => !f.IsHidden);
- }
+ if (i.Attributes.HasFlag(FileAttributes.System))
+ {
+ return false;
+ }
+
+ if (!request.IncludeHidden && i.Attributes.HasFlag(FileAttributes.Hidden))
+ {
+ return false;
+ }
+
+ var isDirectory = i.Attributes.HasFlag(FileAttributes.Directory);
+
+ if (!request.IncludeFiles && !isDirectory)
+ {
+ return false;
+ }
+
+ if (!request.IncludeDirectories && isDirectory)
+ {
+ return false;
+ }
+
+ return true;
+ });
- return fileSystemEntries.Select(f => new FileSystemEntryInfo
+ return entries.Select(f => new FileSystemEntryInfo
{
- Name = f.cFileName,
- Path = f.Path,
- Type = f.IsDirectory ? FileSystemEntryType.Directory : FileSystemEntryType.File
- });
+ Name = f.Name,
+ Path = f.FullName,
+ Type = f.Attributes.HasFlag(FileAttributes.Directory) ? FileSystemEntryType.Directory : FileSystemEntryType.File
+
+ }).ToList();
}
///