gpt4 book ai didi

windows-phone-7 - 如何读取存储在 IsolatedStorage 中的文件名

转载 作者:行者123 更新时间:2023-12-02 06:40:33 24 4
gpt4 key购买 nike

我有一些文件存储在 IsolatedStorage 中。这些文件是不同类型的。我需要获取所有文件的名称。如何从 IsolatedStorage 中读取文件名。只需要文件名。

最佳答案

使用GetFileNames 方法。如果您只想要 IsolatedStorage 根目录中所有文件的名称,您可以

using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
string[] fileNames = store.GetFileNames();
}

如果您也想要其他目录中的文件名,可以使用 GetDirectoryNames 方法获取所有目录名以检索根级别的所有目录名。

GetFileNamesGetDirectoryNames 也有重载方法,它们采用搜索模式字符串并返回与该模式匹配的所有文件/目录的名称。

因此,为了获取某个目录中的文件名,您可以

string searchPattern = directory + "\\*";
string[] fileNames = store.GetFileNames(searchPattern);

这将为您提供存储在 directory 目录中的所有文件的名称。

获取目录名称:http://msdn.microsoft.com/en-us/library/cc190673.aspx

获取文件名:http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.getfilenames%28v=vs.95%29.aspx

关于windows-phone-7 - 如何读取存储在 IsolatedStorage 中的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8967263/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com