File.Exists() and URI?

  • Thread starter Thread starter Gustaf Liljegren
  • Start date Start date
G

Gustaf Liljegren

I have a document with links written in the URI syntax, like this:

file:///c:/folder/example1.xml
file:///c:/folder/example2.xml

I want to check if these file exists before I read them, but the
IO.File.Exists() method doesn't seem to handle the URI syntax. Is there an
alternative way for URIs, or do I need to parse the URIs and write them as
Windows file paths?

Thanks,

Gustaf
 
Gustaf,

You can pass the URL to the Uri class constructor. Once you have an Uri
instance, you can get the filename using the LocalPath property, which
returns the local operating-system representation of a filename.

Hope this helps.
 
Back
Top