-2

I have a WPF application. I am loading some data from XML file.

I receive an error:

System.NotSupportedException was unhandled
Message: The given path's format is not supported.

on this line:

string html = File.ReadAllText(Advertisement.DescriptionUrl);

the url in the xml it is:

http://mysitetest.com/x/x/Assets/shop/shopdetails/Coffee/image.png

Any ideas how to fix it?

2
  • please guys add a comment when down-voting thanks
    – GibboK
    Nov 25, 2013 at 11:48
  • 1
    If we let the fact that File.ReadAllText does not handle url's, image.png is hardly going to be a text file, so reading it as text will likely not be what you want. Nov 25, 2013 at 11:51

2 Answers 2

2

File.ReadAllText is meant to take a filename on a file system - not a URL.

You'll need to fetch it with something like WebClient.DownloadString:

string text;
using (WebClient client = new WebClient())
{
    text = client.DownloadString(url);
}
// Now use text
0
1

That's a web URL, not a file path.

Use a WebClient object to request the resource:

string html;
using (WebClient client = new WebClient()) {
  html = client.DownloadString(Advertisement.DescriptionUrl);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.