I read the example in here.
But it returns the error, how to solve the error?
I believe you're missing an import statement at the top of your code.
As mentioned in These Microsoft Docs which show that the method you're calling is present in System.IO and in your linked answer/post you're likely missing the top part of the answer you seem to have copied.
Quote
so add this to the imports section
Import System.IO