windows phone 7 File Listing IsolatedStorage

2019-08-29 07:31发布

问题:

i have a problem when i want get list of file in a directory

this is my code

try
        {
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                StringBuilder sb = new StringBuilder();
                string subDir = Path.Combine("NotesYours", "Notes");
                if (store.DirectoryExists(subDir))
                {

                    string searchPath = Path.Combine(subDir, "*");
                    string[] fileInSubDir = store.GetFileNames(searchPath);
                    tbtbtes.Text = fileInSubDir.Length.ToString();
                }
                else
                {
                    MessageBox.Show("dir not exist");
                }
            }
        }
        catch (IsolatedStorageException)
        {

        }

length if fileInSubDir is zero, whereas i have created three file before, So it must be the Length of fileInSubDir is Three, not zero

please help me :(

回答1:

I half remember a bug which meant wildcard searches just using * in GetFileNames didn't work correctly.
Have you verified that the files are there or tried using a less generic search term?