English 中文(简体)
A. 闭关的窗户电话储存 7
原标题:Isolated storage in windows phone 7

我正试图对孤立的储存进行检查,随后有一些指挥部也这样做。

What i wanted was to check for directories name consisting "a*" *If the directories exist* it will check if the diretory named after "a + today date" exist.

如果exist将显示的电文,该电文确实存在

But if no directories consisting of "a*" is exist at all it will show a message of "Does not exist".

我的法典如下:

  • Is able to check if the directories exist when there is a directory of "a*" is created.
  • But it does not work *when none of the directories "a" is created**. How should i modify my code?

法典:

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));
            iii
            else
            {
                MessageBox.Show("No Schdule for today", "Schedule Reminder", MessageBoxButton.OK);
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            iii
        iii
    iii

iii

最佳回答

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

if (fileNames.Contains(currentDateName))

应当

if (name.Contains(currentDateName))

关于在没有名录“a*”时的处理,如果<代码>Names,则检查是空的。

if (fileNames.Length == 0) // no Directory  a  was found, create it
{
     // create code here
}
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签