DarioDP
DarioDP

Reputation: 627

How can I check file extension of a file in IsolatedStorage?

I need to populate 2 lists in my application. The first list should contain only .txt files while the second one should contain .jpg files.

Now what I do is something like:

    foreach (string file in fileList)
                    {

                        if (file != "__ApplicationSettings")
                        {
                           ...
                        }
                     }

But how can I also check file extension?

Thanks in advance.

Upvotes: 1

Views: 237

Answers (1)

Jim Mischel
Jim Mischel

Reputation: 133995

Using the Path.GetExtension method:

if (Path.GetExtension(file) != ".jpg")
{
    ...
}

Upvotes: 2

Related Questions