///<inheritdoc> public async Task <IFileSystemItemMetadata> GetMetadataAsync() { // Return IFileMetadata for a file, IFolderMetadata for a folder. if (File.Exists(RemoteStoragePath)) { return(Mapping.GetUserFileSysteItemMetadata(new FileInfo(RemoteStoragePath))); } else if (Directory.Exists(RemoteStoragePath)) { return(Mapping.GetUserFileSysteItemMetadata(new DirectoryInfo(RemoteStoragePath))); } return(null); }
/// <inheritdoc/> public async Task GetChildrenAsync(string pattern, IOperationContext operationContext, IFolderListingResultContext resultContext) { Logger.LogMessage($"{nameof(IFolder)}.{nameof(GetChildrenAsync)}({pattern})", UserFileSystemPath); IEnumerable <FileSystemInfo> remoteStorageChildren = new DirectoryInfo(RemoteStoragePath).EnumerateFileSystemInfos(pattern); List <IFileSystemItemMetadata> userFileSystemChildren = new List <IFileSystemItemMetadata>(); foreach (FileSystemInfo remoteStorageItem in remoteStorageChildren) { IFileSystemItemMetadata itemInfo = Mapping.GetUserFileSysteItemMetadata(remoteStorageItem); userFileSystemChildren.Add(itemInfo); } // To signal that the children enumeration is completed // always call ReturnChildren(), even if the folder is empty. resultContext.ReturnChildren(userFileSystemChildren.ToArray(), userFileSystemChildren.Count); }