user569574
user569574

Reputation: 99

getting the file in a sub-folder @ Isolated Storage - WP7

I would like to get all the files that a sub-folder holds in a string array.

So, I have tried something like the following:

var IOstore = IsolatedStorageFile.GetUserStoreForApplication();
string searchpath = System.IO.Path.Combine("product", ProductName);
string filesInSubDirs[] = IOstore.GetFileNames(searchpath);

But I got all the files in the "product" folder. I have also tried with "productname" only as the parameter.

Thanks for your help.

Upvotes: 0

Views: 1502

Answers (2)

DevTheo
DevTheo

Reputation: 921

Something you might want to try. (this is sort of a left field answer, sorry). In my dropbox client http://sharpdropbox.codeplex.com/) I have a set of facades for System.IO.File, System.IO.FileInfo, System.IO.Directory, and System.IO.DirectoryInfo. They work pretty good and I have tested them.

Basically, you add a Using or Import for System.IO.IsolatedStorage and then PSFile, PSDirectory, PSFileInfo, or PSDirectoryInfo. It's saved me from having to remember all the nuances... for instance if you are querying a directory, it knows to add a slash, etc. BTW, the "PS" prefix stands for "Persisted Storage" which is what IsolatedStorage is sometimes called (starting them with an "I" implies they are interfaces.. and having no prefix makes things even more confusing).

Anyway, you can grab the code from source or I believe the last release had the DLLs for them (it's called something like "IsolatedStorageFacade-WP7")

Upvotes: 0

Derek Lakin
Derek Lakin

Reputation: 16319

The search pattern for a sub-folder needs to include "*.*" at the end to pattern match any file, which would make your code something like the following:

var IOstore = IsolatedStorageFile.GetUserStoreForApplication();
string searchpath = System.IO.Path.Combine("product", ProductName);
searchpath = string.Format("{0}\\*.*", searchpath);
string filesInSubDirs[] = IOstore.GetFileNames(searchpath);

Upvotes: 5

Related Questions