I have searched everywhere for a code sample but for the life of me I cannot find a working solution to get all files/folders in a particular folder in an Indexer library I am coding as a Portable Class Library.
I was linked to What need I do to get this code to work in a Portable Class Library? after I had a cast error question at Unable to cast object of type 'System.IO.FileSystemInfo[]' to type 'System.Collections.Generic.IEnumerable`1[System.IO.DirectoryInfo] however PCLStorage is limited to LocalStorage which is the app folder.
private async Task<List<IFolder>> GetDirectoriesAsync(string startingDir)
{
IFolder rootFolder = FileSystem.Current.LocalStorage;
IFolder folder = await rootFolder.GetFolderAsync(startingDir, System.Threading.CancellationToken.None);
IList<IFolder> folders = await folder.GetFoldersAsync(System.Threading.CancellationToken.None);
return folders.ToList();
}
I wanted for the user to be able to pick any folder i.e. C:\ or external drive or anywhere that the user can browse.
Thanks in advance.
My full code is at: IndexerLib