URL Formats are not supported

asp.net, c#

Solution

You could either use a WebClient as suggested in other answers or fetch the relative path like this:

var url = "http://localhost:10001/MyFiles/folder/abc.png";

var uri = new Uri(url);
var path = Path.GetFileName(uri.AbsolutePath);

var file = GetFile(path);
// ...

In general you should get rid of the absolute URLs.

Problem

I am reading File with File.OpenRead method, I am giving this path ``` http://localhost:10001/MyFiles/folder/abc.png ``` I have tried this as well but no luck ``` http://localhost:10001//MyFiles//abc.png ``` but its giving URL Formats are not supported When I give physical path of my Drive like this,It works fine d:\MyFolder\MyProject\MyFiles\folder\abc.png How can I give file path to an Http path? this is my code ``` public FileStream GetFile(string filename) { FileStream file = File.OpenRead(filename); return file; } ```

Original source

Related problems