首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >windows phone 7中的隔离存储

windows phone 7中的隔离存储
EN

Stack Overflow用户
提问于 2011-07-29 06:33:04
回答 1查看 443关注 0票数 0

我正在尝试检查隔离存储,然后是一些命令以及它。

我想要的是检查包含"a*" *的目录名,如果目录存在*它将检查以"a +今天日期“命名的目录是否存在。

如果存在,将显示一条弹出消息,告诉它确实存在

但是,如果没有包含"a*“的目录是存在的,则将显示”不存在“的消息。

下面是我的代码:

如果存在"a*“的created.

  • But目录,则
  • 可以检查目录是否存在,如果没有创建目录"a”,则无法工作**。如何修改我的代码?

代码:

代码语言:javascript
复制
string[] fileNames;
string selectedFolderName;

private void gameBtn_Click(object sender, RoutedEventArgs e)
{
    //MediaPlayer.Stop();

    string currentDate = DateTime.Now.ToString("MMddyyyy");
    string currentDateName = "a" + currentDate;


    IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();

        fileNames = myStore.GetDirectoryNames("a*");

        foreach (var name in fileNames)
        {
            if (fileNames.Contains(currentDateName))
            {
                selectedFolderName = currentDateName;
                MessageBox.Show("Your schedule for today");
                NavigationService.Navigate(new Uri("/DisplaySchedule.xaml?selectedFolderName=" + selectedFolderName, UriKind.Relative));
            }
            else
            {
                MessageBox.Show("No Schdule for today", "Schedule Reminder", MessageBoxButton.OK);
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }
        }
    }

}

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-07-29 07:09:16

你的错误只是一个简单的错误。

代码语言:javascript
复制
if (fileNames.Contains(currentDateName))

应该是

代码语言:javascript
复制
if (name.Contains(currentDateName))

至于在没有目录"a*“时进行处理,请检查fileNames是否为空。

代码语言:javascript
复制
if (fileNames.Length == 0) // no Directory 'a' was found, create it
{
     // create code here
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6869461

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档