1

In Windows Store App's(c#) I check if file exist in nested folder in isolated storage with using this method:

public static async Task<bool> CheckIsFile(string fileName, StorageFolder folder) 
    {
        if (string.IsNullOrEmpty(fileName)) return false;
        try
        {
            await folder.GetFileAsync(fileName); 
            return true; //exist
        }
        catch
        {
            return false; // not exist
        }
    }

But may be exist another (low performance) way without creating exception ?

jimpanzer
  • 3,470
  • 4
  • 44
  • 84

1 Answers1

0

I've never heard of any way to do this except what you have there. It's kind of expensive because you're relying on the exception being thrown, but that's just the way it is right now. For now.

Actually, I believe most methods from Win8 Development that return null are actually just eating up exceptions thrown to return a null. Similar to methods like TryGetSomething.

aiapatag
  • 3,355
  • 20
  • 24
  • Thanks for answer. Realy i'm looking for something like in wp (IsolatedStorage.FileExists(filePath)). but can't find it in win 8(( – jimpanzer Jun 10 '13 at 08:25
  • In practice, if you have 2 or 3 or 10 files - this method works great. But if 1000+ - oh... it's fearful. – jimpanzer Jun 10 '13 at 08:31