进入正题:
一开始直接使用GetDirectoryNames("folder")
string[] folderlist; IsolatedStorageFile iso=IsolatedStorageFile.GetUserStoreForApplication();
if(iso.DirectoryExists("folder"))
{
folderlist=iso.GetDirectoryNames("folder");
}
运行后发现这样写并不能获取到folder的子文件夹,经过一番折磨后发现问题出在GetDirectoryNames的参数,看看GetDirectoryNames的定义:
public string[] GetDirectoryNames();
//
// 摘要:
// 枚举独立存储范围中与给定模式匹配的目录。
//
// 参数:
// searchPattern:
// 搜索模式。单字符 ("?") 和多字符 ("*") 通配符都受支持。
//
// 返回结果:
// 独立存储范围中与 searchPattern 匹配的目录的相对路径 System.Array。零长度数组指定没有任何匹配的目录。
GetDirectoryNames的搜索模式。单字符 ("?") 和多字符 ("*") 通配符都受支持。于是问题也就明白了。正确代码:
string[] folderlist;
IsolatedStorageFile iso=IsolatedStorageFile.GetUserStoreForApplication();
if(iso.DirectoryExists("folder"))
{
folderlist=iso.GetDirectoryNames(System.IO.Path.Combine("folder", "*"));
- 下一篇: 美国声称伊斯兰国指挥官在非洲被杀
- 上一篇: 玩家必备攻略"神兽互娱有挂吗"详细开挂教程(确实是有挂)