如何在Windows Phone 8上获取文件夹中的文件?

时间:2013-01-28 06:47:21

标签: windows-phone-8

如何在Windows Phone 8上获取文件夹中的文件列表?

2 个答案:

答案 0 :(得分:2)

   IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
   if(file.GetDirectoryNames().Contains("Personal"))
        {


            string directory = "Personal/";
            string[] filenames = file.GetFileNames(directory);
            List<FileData> files = new List<FileData>();
            foreach(string filename in filenames)
            {
                FileData f = new FileData();
                f.filename = filename;
                files.Add(f);

            }

            lstFiles.ItemsSource = files;
        }

这只是从名为Personal

的目录中检索文件的代码段

答案 1 :(得分:1)

在Windows Phone 8中,您应该使用StorageFile和StorageFolder API:
Quickstart: Working with files and folders in Windows Phone 8