Reputation: 23
I am trying to read the contents of a *.jsp file and need to retrieve a specific string.
I tried many file handling methods in C# but it seems all work only with txt files. Is it possible to use the same methods for a file with a different extension?
Upvotes: 0
Views: 1827
Reputation: 1500615
The normal IO classes in .NET don't depend on the file extension. You should be able to use:
string jsp = File.ReadAllText("page.jsp");
... assuming the JSP is encoded in UTF-8. You should find out the encoding of the file and load it using that encoding. I wouldn't be surprised if that turned out to be the problem you were having, although you haven't specified anything.
Upvotes: 3