Question: I get this error when I try running my app in the simulator. The error is:

> 
> An error was encountered while running (Domain = LaunchServicesError, Code = 0)
> 
> 
> 

I tried changing the name of the app and this happened.
Furthermore, I tried cleaning the product and it didn't do anything, still having the same error of:

> 
> Unable to run app in Simulator. An error was encountered while running (Domain = LaunchServicesError, Code=0) 
> 
> 
> 

I also tried changing the name back to what it used to be in the Info file which you can see at `postimg.org/image/erieubblp/`. But it didn't change anything.
If you need anything else let me know.

I've also done a Reset content and settings on the simulator.

Also, I checked all the other forum posts on this error and nothing worked.

Answer: 
Do it twice,

```
for (int pageNum = 0; pageNum <= 20; pageNum++)
{   
    //templateFiles is list of files in that directory
    string expectedTemplateName1 = string.Format("{0}_{1}.txt", directoryName, pageNum.ToString());
    string expectedTemplateName2 = string.Format("{0}_{1}.txt", directoryName, pageNum.ToString("00"));
    templateFiles.Any(file => 
        (file.Equals(expectedTemplateName1, StringComparison.OrdinalIgnoreCase) || 
        file.Equals(expectedTemplateName2, StringComparison.OrdinalIgnoreCase)));
}

```
Regular expressions are probably not the best tool in this case, which is why I would just go with @kennyzx's straight forward approach. If you desperately want to use a regex, you could go with the following; But be aware that this is >800% slower than the direct string comparison - and not necessarily easier to understand, either.

```
for (int pageNum = 0; pageNum <= 20; pageNum++)
{   
    var regex = new Regex(string.Format(@"^{0}_(?:{1}|{1:00})\.txt$", directoryName, pageNum), RegexOptions.IgnoreCase);
    templateFiles.Any(file => regex.IsMatch(expectedTemplateName, StringComparison.OrdinalIgnoreCase));
}

```