protected async static Task <string []> GetDirectoryNamesAsync(Windows.Storage.StorageFolder fldr, string wildcard) { IReadOnlyList <Windows.Storage.StorageFolder> subfolders = await fldr.GetFoldersAsync(); RscWildCard wc = new RscWildCard(wildcard); string [] astr = new String[subfolders.Count]; int iLenSave = astr.Length; int i = 0; foreach (Windows.Storage.StorageFolder folder in subfolders) { if (wc.Wanted(folder.Name)) { astr[i] = folder.Name; i++; } } if (i == 0) { return new String [] {} } ; //All filtered out... if (i == iLenSave) { return(astr); //All wanted... } //Not so nice... :( string [] astr2 = new String[i]; for (int j = 0; j < i; j++) { astr2[j] = astr[j]; } return(astr2); }
public override string [] GetFolderNames(string path, string wildcard, bool bIncludeHidden, bool bStartWithInfChr) { int length = 0; string [] aPath = PathParts(path, out length); if (length == 0 && (wildcard.Length == 0 || wildcard == "*.*")) { if (bStartWithInfChr) { return new String [] { "nPictures" } } ; //Normal... else { return new String [] { "Pictures" } }; } else if (length == 1 && aPath[0].ToLower().CompareTo("media library") == 0 && (wildcard.Length == 0 || wildcard == "*.*")) { //Known Folder integration... if (bStartWithInfChr) { return new String [] { "nPictures" } } ; //Normal... else { return new String [] { "Pictures" } }; } else { bool bPictures = false; int iLevelStart = 0; if (length > 0) { if (aPath[0].ToLower().CompareTo("pictures") == 0) { bPictures = true; iLevelStart = 1; } } if (length > 1) { //Known Folder integration... if (aPath[0].ToLower().CompareTo("media library") == 0) { if (aPath[1].ToLower().CompareTo("pictures") == 0) { bPictures = true; iLevelStart = 2; } } } if (bPictures) { MediaLibrary MedLib = new MediaLibrary(); PictureAlbum pa = MedLib.RootPictureAlbum; bool bHit = false; for (int iPos = iLevelStart; iPos < length; iPos++) { foreach (PictureAlbum paHit in pa.Albums) { if (paHit.Name.ToLower().CompareTo(aPath[iPos].ToLower()) == 0) { bHit = true; pa = paHit; break; } } if (!bHit) { return new String [] {} } ; //Album not found... } if (pa.Albums.Count == 0) { return new String [] {} } ; //No Sub Album... RscWildCard wc = new RscWildCard(wildcard); string [] astr = new String[pa.Albums.Count]; int iLenSave = astr.Length; int i = 0; foreach (PictureAlbum paHit in pa.Albums) { if (wc.Wanted(paHit.Name)) { if (bStartWithInfChr) { astr[i] = "n"; //Normal... } else { astr[i] = ""; } astr[i] += paHit.Name; i++; } } if (i == 0) { return new String [] {} } ; //All filtered out... if (i == iLenSave) { return(astr); //All wanted... } //Not so nice... :( string [] astr2 = new String[i]; for (int j = 0; j < i; j++) { astr2[j] = astr[j]; } return(astr2); } else { return(new String [] {}); } } //return new String [] {}; }
protected async static Task <string []> GetFileNamesAsync(Windows.Storage.StorageFolder fldr, string wildcard) { // // NOT WORKING!!! // /* * else * { * using Windows.Storage.Search; * * if( !fldr.IsCommonFileQuerySupported( CommonFileQuery.DefaultQuery ) ) * throw new Exception( "Unable to query!" ); * * /* * string sTypeFilter = "*"; * if( sSearchPattern.IndexOf( "*." ) == 0 ) * sTypeFilter = sSearchPattern.Substring( 1 ); * else * sTypeFilter = sSearchPattern; //This mustn't working... * * * List<string> lstTypeFilter = new List<string>(); * lstTypeFilter.Add("*"); * * //QueryOptions queryOptions = new QueryOptions(); //CommonFileQuery.DefaultQuery); //, lstTypeFilter); * //queryOptions.UserSearchFilter = sSearchPattern; * * QueryOptions queryOptions = new QueryOptions(); * queryOptions.FolderDepth = Windows.Storage.Search.FolderDepth.Deep; * queryOptions.IndexerOption = Windows.Storage.Search.IndexerOption.UseIndexerWhenAvailable; * //queryOptions.UserSearchFilter = "'" + sSearchPattern + "'"; * * //"'" + Begriff + @"' folder:" + Ordner * //"last quarter" author:(theresa OR lee) folder:MyDocs * * StorageFileQueryResult queryResult = fldr.CreateFileQueryWithOptions(queryOptions); * * IReadOnlyList<StorageFile> subfiles = await queryResult.GetFilesAsync(); * * astr = new String[ subfiles.Count ]; * int i = 0; * foreach (StorageFile file in subfiles) * { * astr[ i ] = file.Name; * i++; * } * } */ IReadOnlyList <Windows.Storage.StorageFile> subfiles = await fldr.GetFilesAsync(); RscWildCard wc = new RscWildCard(wildcard); string [] astr = new String[subfiles.Count]; int iLenSave = astr.Length; int i = 0; foreach (Windows.Storage.StorageFile file in subfiles) { if (wc.Wanted(file.Name)) { astr[i] = file.Name; i++; } } if (i == 0) { return new String [] {} } ; //All filtered out... if (i == iLenSave) { return(astr); //All wanted... } //Not so nice... :( string [] astr2 = new String[i]; for (int j = 0; j < i; j++) { astr2[j] = astr[j]; } return(astr2); }