This seems to be a very odd problem that I cannot figure out for the life of me. I have a path (string) that looks like this:
D:\development\php\bchat\chat\index.php
I need to check if the file in question is a PHP file. I figure the most logical way is to take a substring starting from the . to the end of the string and see if it == .php
So i tried:
bool isphp = (path.Substring(path.LastIndexOf('.')) == ".php") ? true : false;
This always returned false. I thought maybe there was a trailing space at the end screwing me up so i put a TrimEnd() on path before it. But that didn't change anything. So i tried this:
bool isphp = (path.EndsWith(".php") == true) ? true : false;
This also always returns false.
EDIT I have now also tried this:
bool isphp = (Path.GetExtension(path) == ".php");
But this also returns false.